pub struct GuardEvent {
pub guard_type: GuardType,
pub endpoint: String,
pub endpoint_fingerprint: String,
pub endpoint_nickname: Option<String>,
pub status: GuardStatus,
/* private fields */
}Expand description
Event indicating that guard relay status has changed.
Guard events track changes to the entry guards that Tor uses for the first hop of circuits. Entry guards are a security feature that limits the set of relays that can observe your traffic entering the Tor network.
§Guard Types
Currently, only GuardType::Entry is used, representing entry guards.
§Guard Status
Guards can have these statuses:
GuardStatus::New- Newly selected as a guardGuardStatus::Up- Guard is reachableGuardStatus::Down- Guard is unreachableGuardStatus::Good- Guard confirmed as goodGuardStatus::Bad- Guard marked as badGuardStatus::Dropped- Guard removed from list
§Example
ⓘ
use stem_rs::events::GuardEvent;
use stem_rs::GuardStatus;
fn handle_guard(event: &GuardEvent) {
match event.status {
GuardStatus::New => {
println!("New guard: {} ({:?})",
event.endpoint_fingerprint, event.endpoint_nickname);
}
GuardStatus::Down => {
println!("Guard {} is down", event.endpoint_fingerprint);
}
GuardStatus::Dropped => {
println!("Guard {} dropped", event.endpoint_fingerprint);
}
_ => {}
}
}§See Also
GuardType- Guard type valuesGuardStatus- Guard status values
Fields§
§guard_type: GuardTypeType of guard (currently only Entry).
endpoint: StringFull endpoint string (fingerprint with optional nickname).
endpoint_fingerprint: StringRelay fingerprint (40 hex characters).
endpoint_nickname: Option<String>Relay nickname if available.
status: GuardStatusCurrent status of the guard.
Implementations§
Source§impl GuardEvent
impl GuardEvent
Sourcepub fn parse(content: &str) -> Result<Self, Error>
pub fn parse(content: &str) -> Result<Self, Error>
Parses a guard event from raw control protocol content.
§Arguments
content- The event content after the event type
§Event Format
GuardType Endpoint StatusWhere Endpoint is either a fingerprint or fingerprint=nickname.
§Errors
Returns Error::Protocol if:
- Required fields are missing
- The guard type or status is unrecognized
Trait Implementations§
Source§impl Clone for GuardEvent
impl Clone for GuardEvent
Source§fn clone(&self) -> GuardEvent
fn clone(&self) -> GuardEvent
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 GuardEvent
impl Debug for GuardEvent
Source§impl Event for GuardEvent
impl Event for GuardEvent
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 GuardEvent
impl RefUnwindSafe for GuardEvent
impl Send for GuardEvent
impl Sync for GuardEvent
impl Unpin for GuardEvent
impl UnwindSafe for GuardEvent
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