pub struct ConnectionBandwidthEvent {
pub id: String,
pub conn_type: ConnectionType,
pub read: u64,
pub written: u64,
/* private fields */
}Expand description
Event providing bandwidth information for a specific connection.
This event tracks bandwidth usage per connection, categorized by connection type (OR, Dir, Exit). Useful for detailed bandwidth analysis and monitoring.
§Connection Types
ConnectionType::Or- Onion Router connections (relay-to-relay)ConnectionType::Dir- Directory connectionsConnectionType::Exit- Exit connections to the internet
§Example
ⓘ
use stem_rs::events::ConnectionBandwidthEvent;
use stem_rs::ConnectionType;
fn handle_conn_bw(event: &ConnectionBandwidthEvent) {
let type_str = match event.conn_type {
ConnectionType::Or => "OR",
ConnectionType::Dir => "Dir",
ConnectionType::Exit => "Exit",
};
println!("{} connection {}: {} read, {} written",
type_str, event.id, event.read, event.written);
}§See Also
BandwidthEvent- Aggregate bandwidthCircuitBandwidthEvent- Per-circuit bandwidthConnectionType- Connection types
Fields§
§id: StringConnection identifier.
conn_type: ConnectionTypeType of connection.
read: u64Bytes read on this connection.
written: u64Bytes written on this connection.
Implementations§
Source§impl ConnectionBandwidthEvent
impl ConnectionBandwidthEvent
Sourcepub fn parse(content: &str) -> Result<Self, Error>
pub fn parse(content: &str) -> Result<Self, Error>
Parses a connection bandwidth event from raw control protocol content.
§Arguments
content- The event content after the event type
§Event Format
ID=ConnID TYPE=ConnType READ=bytes WRITTEN=bytes§Errors
Returns Error::Protocol if:
- Required fields (ID, TYPE, READ, WRITTEN) are missing
- The connection type is unrecognized
- Numeric values cannot be parsed
Trait Implementations§
Source§impl Clone for ConnectionBandwidthEvent
impl Clone for ConnectionBandwidthEvent
Source§fn clone(&self) -> ConnectionBandwidthEvent
fn clone(&self) -> ConnectionBandwidthEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConnectionBandwidthEvent
impl Debug for ConnectionBandwidthEvent
Source§impl Event for ConnectionBandwidthEvent
impl Event for ConnectionBandwidthEvent
Source§fn event_type(&self) -> EventType
fn event_type(&self) -> EventType
Returns the type of this event. Read more
Source§fn raw_content(&self) -> &str
fn raw_content(&self) -> &str
Returns the raw, unparsed content of the event. Read more
Source§fn arrived_at(&self) -> Instant
fn arrived_at(&self) -> Instant
Returns the instant when this event was received. Read more
Auto Trait Implementations§
impl Freeze for ConnectionBandwidthEvent
impl RefUnwindSafe for ConnectionBandwidthEvent
impl Send for ConnectionBandwidthEvent
impl Sync for ConnectionBandwidthEvent
impl Unpin for ConnectionBandwidthEvent
impl UnwindSafe for ConnectionBandwidthEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more