pub trait Session {
type Event;
// 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 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§
Required Methods§
Sourcefn handle_text(&mut self, text: &str, now: Timestamp) -> Inbound
fn handle_text(&mut self, text: &str, now: Timestamp) -> Inbound
Feed in one frame as it arrived from the transport.
Sourcefn handle_message(&mut self, message: Message, now: Timestamp) -> Inbound
fn handle_message(&mut self, message: Message, now: Timestamp) -> Inbound
Feed in one already-decoded message.
Sourcefn handle_timeout(&mut self, now: Timestamp)
fn handle_timeout(&mut self, now: Timestamp)
Tell the session the time has reached Self::poll_timeout.
Sourcefn transport_closed(&mut self, now: Timestamp)
fn transport_closed(&mut self, now: Timestamp)
Tell the session its transport has gone.
Sourcefn poll_transmit(&mut self) -> Option<Outgoing>
fn poll_transmit(&mut self) -> Option<Outgoing>
Take the next frame to send, if any.
Sourcefn poll_event(&mut self) -> Option<Self::Event>
fn poll_event(&mut self) -> Option<Self::Event>
Take the next event for the application, if any.
Sourcefn poll_timeout(&self) -> Option<Timestamp>
fn poll_timeout(&self) -> Option<Timestamp>
When the session next needs to be woken, if ever.
Sourcefn state(&self) -> &SessionState
fn state(&self) -> &SessionState
Where the session has got to.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".