Skip to main content

Session

Trait Session 

Source
pub trait Session {
    type Event;

Show 13 methods // Required methods fn open(&mut self, now: Timestamp); fn handle_text(&mut self, text: &str, now: Timestamp) -> Inbound; fn handle_message(&mut self, message: Message, now: Timestamp) -> Inbound; fn handle_timeout(&mut self, now: Timestamp); fn transport_closed(&mut self, now: Timestamp); fn poll_transmit(&mut self) -> Option<Outgoing>; fn poll_event(&mut self) -> Option<Self::Event>; fn poll_timeout(&self) -> Option<Timestamp>; fn state(&self) -> &SessionState; fn negotiated_version(&self) -> Option<&ProtocolVersion>; fn registry(&self) -> &Registry; fn stats(&self) -> Stats; fn close(&mut self);
}
Expand description

What both engines have in common: four calls in, three out, and a clock that is always a parameter.

The trait exists so that code which only pumps a session — SessionSet, crate::io::Driver, a test harness — does not need to know which role it is pumping. Neither engine is written against it; it describes what they already are.

It is deliberately not object-safe in spirit but is in fact: Self::Event keeps the two event enums distinct, because a CEM that receives RmEvent::Instruction would be a confusion, not a convenience.

Required Associated Types§

Source

type Event

What this side tells its application about.

Required Methods§

Source

fn open(&mut self, now: Timestamp)

Begin. Has no effect on a session that is already open.

Source

fn handle_text(&mut self, text: &str, now: Timestamp) -> Inbound

Feed in one frame as it arrived from the transport.

Source

fn handle_message(&mut self, message: Message, now: Timestamp) -> Inbound

Feed in one already-decoded message.

Source

fn handle_timeout(&mut self, now: Timestamp)

Tell the session the time has reached Self::poll_timeout.

Source

fn transport_closed(&mut self, now: Timestamp)

Tell the session its transport has gone.

Source

fn poll_transmit(&mut self) -> Option<Outgoing>

Take the next frame to send, if any.

Source

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

Take the next event for the application, if any.

Source

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

When the session next needs to be woken, if ever.

Source

fn state(&self) -> &SessionState

Where the session has got to.

Source

fn negotiated_version(&self) -> Option<&ProtocolVersion>

The version string the handshake settled on, once it has.

Source

fn registry(&self) -> &Registry

Everything the session has learned about its peer.

Source

fn stats(&self) -> Stats

What this session has done, for an operator’s metrics.

Source

fn close(&mut self)

Queue a close.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§