Driver

Trait Driver 

Source
pub trait Driver {
    type Event;
    type Error;

    // Required methods
    fn handle_input(
        &mut self,
        now: Instant,
        peer: SocketAddr,
        bytes: &[u8],
    ) -> Result<(), Self::Error>;
    fn handle_timeout(&mut self, now: Instant);
    fn poll_transmit(&mut self, now: Instant) -> Option<Transmit<'_>>;
    fn poll_event(&mut self) -> Option<Self::Event>;
    fn poll_timeout(&self) -> Option<Instant>;
}
Expand description

Sans-io driver. Mirrors quinn-proto::Connection and rustls::Connection.

The shell calls these methods in a loop. The core never calls back into the shell. Time is injected via the now: Instant parameter on every call — implementors of this trait must NOT consult Instant::now() themselves.

Required Associated Types§

Source

type Event

Consumer-visible event type.

Source

type Error

Per-protocol structured error type.

Required Methods§

Source

fn handle_input( &mut self, now: Instant, peer: SocketAddr, bytes: &[u8], ) -> Result<(), Self::Error>

Feed an inbound datagram. Parses, advances state, may push events / outbound packets / timer updates.

§Errors

Returns the protocol-specific error if the bytes cannot be parsed.

Source

fn handle_timeout(&mut self, now: Instant)

Tell the core that wall time has advanced.

Source

fn poll_transmit(&mut self, now: Instant) -> Option<Transmit<'_>>

Pop the next outbound datagram, if any.

Source

fn poll_event(&mut self) -> Option<Self::Event>

Pop the next consumer-visible event.

Source

fn poll_timeout(&self) -> Option<Instant>

Earliest instant at which the core needs to be re-entered.

None means “no pending timer — only wake me on input”.

Implementors§