pub struct OrConnEvent {
pub id: Option<String>,
pub status: OrStatus,
pub target: String,
pub reason: Option<OrClosureReason>,
pub num_circuits: Option<u32>,
/* private fields */
}Expand description
Event indicating that an OR (Onion Router) connection status has changed.
OR connection events track the status of connections between Tor relays. These are the TLS connections that carry circuit traffic between nodes in the Tor network.
§Connection Lifecycle
OR connections progress through these states:
OrStatus::New- Connection initiatedOrStatus::Launched- Connection attempt in progressOrStatus::Connected- TLS handshake completedOrStatus::FailedorOrStatus::Closed- Connection terminated
§Example
ⓘ
use stem_rs::events::OrConnEvent;
use stem_rs::OrStatus;
fn handle_orconn(event: &OrConnEvent) {
match event.status {
OrStatus::Connected => {
println!("Connected to relay: {}", event.target);
}
OrStatus::Failed | OrStatus::Closed => {
println!("Connection to {} ended: {:?}", event.target, event.reason);
}
_ => {}
}
}§See Also
OrStatus- OR connection status valuesOrClosureReason- Closure reasons
Fields§
§id: Option<String>Connection identifier (may be None for older Tor versions).
status: OrStatusCurrent status of the OR connection.
target: StringTarget relay address (IP:port or fingerprint).
reason: Option<OrClosureReason>Reason for connection closure.
num_circuits: Option<u32>Number of circuits using this connection.
Implementations§
Source§impl OrConnEvent
impl OrConnEvent
Sourcepub fn parse(content: &str) -> Result<Self, Error>
pub fn parse(content: &str) -> Result<Self, Error>
Parses an OR connection event from raw control protocol content.
§Arguments
content- The event content after the event type
§Event Format
Target Status [REASON=...] [NCIRCS=...] [ID=...]§Errors
Returns Error::Protocol if:
- Required fields are missing
- The status is not a recognized value
Trait Implementations§
Source§impl Clone for OrConnEvent
impl Clone for OrConnEvent
Source§fn clone(&self) -> OrConnEvent
fn clone(&self) -> OrConnEvent
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 OrConnEvent
impl Debug for OrConnEvent
Source§impl Event for OrConnEvent
impl Event for OrConnEvent
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 OrConnEvent
impl RefUnwindSafe for OrConnEvent
impl Send for OrConnEvent
impl Sync for OrConnEvent
impl Unpin for OrConnEvent
impl UnwindSafe for OrConnEvent
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