pub trait Event: Send + Sync {
// Required methods
fn event_type(&self) -> EventType;
fn raw_content(&self) -> &str;
fn arrived_at(&self) -> Instant;
}Expand description
Trait implemented by all Tor control protocol events.
This trait provides a common interface for accessing event metadata
regardless of the specific event type. All event types must be thread-safe
(Send + Sync) to support concurrent event handling.
§Implementors
All event structs in this module implement this trait:
BandwidthEvent,LogEvent,CircuitEvent,StreamEventOrConnEvent,AddrMapEvent,BuildTimeoutSetEventGuardEvent,NewDescEvent,SignalEvent,StatusEventConfChangedEvent,NetworkLivenessEvent,CircuitBandwidthEventConnectionBandwidthEvent,HsDescEvent
§Example
ⓘ
fn handle_event(event: &dyn Event) {
println!("Received {:?} event at {:?}", event.event_type(), event.arrived_at());
println!("Raw content: {}", event.raw_content());
}Required Methods§
Sourcefn event_type(&self) -> EventType
fn event_type(&self) -> EventType
Returns the type of this event.
This corresponds to the event keyword used in SETEVENTS commands.
Sourcefn raw_content(&self) -> &str
fn raw_content(&self) -> &str
Returns the raw, unparsed content of the event.
Useful for debugging or when additional parsing is needed beyond what the typed event provides.
Sourcefn arrived_at(&self) -> Instant
fn arrived_at(&self) -> Instant
Returns the instant when this event was received.
This is the local time when the event was parsed, not when Tor generated it. Useful for measuring event latency or ordering events.