Skip to main content

Endpoint

Trait Endpoint 

Source
pub trait Endpoint: 'static {
    // Required method
    fn on_datagram(&mut self, cx: &mut UdpCtx<'_>, data: &[u8], meta: &RecvMeta);

    // Provided methods
    fn on_timer(&mut self, cx: &mut UdpCtx<'_>, token: u64) { ... }
    fn on_message(&mut self, cx: &mut UdpCtx<'_>, msg: Message) { ... }
    fn on_stop(&mut self, cx: &mut UdpCtx<'_>) { ... }
    fn is_busy(&self) -> bool { ... }
    fn on_abort(&mut self, cx: &mut UdpCtx<'_>) { ... }
}
Expand description

A UDP endpoint (for QUIC, a whole connection table) on one loop.

Required Methods§

Source

fn on_datagram(&mut self, cx: &mut UdpCtx<'_>, data: &[u8], meta: &RecvMeta)

A datagram arrived. With GRO on, data may hold several datagrams of meta.segment_size bytes each. The buffer is reused once this returns.

Provided Methods§

Source

fn on_timer(&mut self, cx: &mut UdpCtx<'_>, token: u64)

A timer set with UdpCtx::set_timer expired.

Source

fn on_message(&mut self, cx: &mut UdpCtx<'_>, msg: Message)

A message from another thread arrived.

Source

fn on_stop(&mut self, cx: &mut UdpCtx<'_>)

The runtime is stopping gracefully. Start winding down (QUIC: GOAWAY, then close each connection once its streams finish). The loop keeps serving this endpoint, with its datagrams, timers and messages, while Endpoint::is_busy says so and the grace period lasts; then the socket is closed.

Source

fn is_busy(&self) -> bool

Whether the endpoint still has work in flight. Asked after every loop turn once the runtime is stopping: while it is true (and the grace period lasts) the loop stays alive. The default is false: the socket closes as soon as the TCP side is done.

Source

fn on_abort(&mut self, cx: &mut UdpCtx<'_>)

The grace period ran out while the endpoint was still busy: close everything now (QUIC: send CONNECTION_CLOSE). The socket is closed right after.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§