pub enum VCLEvent {
Connected,
Disconnected,
PacketReceived {
sequence: u64,
size: usize,
},
PingReceived,
PongReceived {
latency: Duration,
},
KeyRotated,
Error(String),
}Expand description
Events emitted by a VCLConnection.
Received via the mpsc::Receiver<VCLEvent> returned by
VCLConnection::subscribe().
§Example
use vcl_protocol::{VCLEvent, connection::VCLConnection};
#[tokio::main]
async fn main() {
let mut conn = VCLConnection::bind("127.0.0.1:0").await.unwrap();
let mut events = conn.subscribe();
tokio::spawn(async move {
while let Some(event) = events.recv().await {
match event {
VCLEvent::Connected => println!("Ready!"),
VCLEvent::PongReceived { latency } =>
println!("Latency: {:?}", latency),
VCLEvent::Disconnected => break,
_ => {}
}
}
});
}Variants§
Connected
Handshake completed — the connection is ready to send and receive data.
Disconnected
close() was called — connection is now shut down.
PacketReceived
A data packet was successfully received and decrypted.
Fields
PingReceived
The peer sent a Ping — a Pong was sent back automatically.
PongReceived
A Pong was received in response to our ping() call.
KeyRotated
Mid-session key rotation completed — both sides now use the new shared secret.
Error(String)
A non-fatal internal error occurred.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VCLEvent
impl RefUnwindSafe for VCLEvent
impl Send for VCLEvent
impl Sync for VCLEvent
impl Unpin for VCLEvent
impl UnsafeUnpin for VCLEvent
impl UnwindSafe for VCLEvent
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