pub struct CemSession { /* private fields */ }Expand description
A Customer Energy Manager’s side of one S2 session.
The mirror of RmSession, over the same core: the same state
table, the same acknowledgement ledger, the same registry. Wiring one of each
together through crate::testing::Conversation is how the documented conversations are
tested.
Implementations§
Source§impl CemSession
impl CemSession
Sourcepub fn set_inbound_policy(&mut self, policy: Box<dyn InboundPolicy + Send>)
pub fn set_inbound_policy(&mut self, policy: Box<dyn InboundPolicy + Send>)
Install a hook consulted before every inbound message is acknowledged.
Sourcepub fn state(&self) -> &SessionState
pub fn state(&self) -> &SessionState
Where the session has got to.
Sourcepub fn profile(&self) -> WireProfile
pub fn profile(&self) -> WireProfile
The wire profile in use.
Sourcepub fn negotiated_version(&self) -> Option<&ProtocolVersion>
pub fn negotiated_version(&self) -> Option<&ProtocolVersion>
The version string the handshake settled on, exactly as it crossed the wire —
or the pre-negotiated one under S2 Connect. None until then.
profile is what the codec reads with; this is what an operator
greps for, and the evidence R2’s trigger is evaluated on: which string a peer
actually selects.
Sourcepub fn stats(&self) -> Stats
pub fn stats(&self) -> Stats
What this session has done, for an operator’s metrics rather than for the application: how many messages crossed, how many were refused, and how long the peer takes to answer.
Sourcepub fn details(&self) -> Option<&ResourceManagerDetails>
pub fn details(&self) -> Option<&ResourceManagerDetails>
The resource’s details, once it has sent them.
Sourcepub fn open(&mut self, now: Timestamp)
pub fn open(&mut self, now: Timestamp)
Begin.
With a handshake, this queues one — the Resource Manager also sends one, and neither order is wrong. With a version already agreed, it does nothing but wait for the resource’s details.
Sourcepub fn poll_transmit(&mut self) -> Option<Outgoing>
pub fn poll_transmit(&mut self) -> Option<Outgoing>
The next message to put on the wire.
Sourcepub fn poll_event(&mut self) -> Option<CemEvent>
pub fn poll_event(&mut self) -> Option<CemEvent>
The next thing the application needs to know.
Sourcepub fn poll_timeout(&self) -> Option<Timestamp>
pub fn poll_timeout(&self) -> Option<Timestamp>
When handle_timeout next has something to do.
Sourcepub fn handle_text(&mut self, text: &str, now: Timestamp) -> Inbound
pub fn handle_text(&mut self, text: &str, now: Timestamp) -> Inbound
Feed in one text frame. Never fails.
A frame that arrives after the session is over is ignored rather than answered:
the transport is gone, so an acknowledgement queued for it is one nobody will
ever read — and a closed session that keeps filling its outbox is a closed
session that keeps growing. handle_message makes the
same check; this one is for the frames that never get that far.
Sourcepub fn handle_message(&mut self, message: Message, now: Timestamp) -> Inbound
pub fn handle_message(&mut self, message: Message, now: Timestamp) -> Inbound
Feed in one already-decoded message.
Sourcepub fn handle_timeout(&mut self, now: Timestamp)
pub fn handle_timeout(&mut self, now: Timestamp)
Let time pass.
Sourcepub fn transport_closed(&mut self, now: Timestamp)
pub fn transport_closed(&mut self, now: Timestamp)
The transport went away.
Sourcepub fn select_control_type(
&mut self,
control_type: ControlType,
now: Timestamp,
) -> Result<MessageHandle, SendError>
pub fn select_control_type( &mut self, control_type: ControlType, now: Timestamp, ) -> Result<MessageHandle, SendError>
Activate a control type.
The session does not become active until the resource acknowledges it, which is
when CemEvent::Ready arrives.
Sourcepub fn instruct(
&mut self,
instruction: impl Into<Message>,
now: Timestamp,
) -> Result<MessageHandle, SendError>
pub fn instruct( &mut self, instruction: impl Into<Message>, now: Timestamp, ) -> Result<MessageHandle, SendError>
Send an instruction.
Sourcepub fn revoke(
&mut self,
object_type: RevokableObjects,
object_id: Id,
now: Timestamp,
) -> Result<MessageHandle, SendError>
pub fn revoke( &mut self, object_type: RevokableObjects, object_id: Id, now: Timestamp, ) -> Result<MessageHandle, SendError>
Withdraw something published earlier.
Sourcepub fn request_session(
&mut self,
request: SessionRequestType,
diagnostic: Option<String>,
now: Timestamp,
) -> Result<MessageHandle, SendError>
pub fn request_session( &mut self, request: SessionRequestType, diagnostic: Option<String>, now: Timestamp, ) -> Result<MessageHandle, SendError>
Ask the peer to end or restart the session.
Trait Implementations§
Source§impl Debug for CemSession
impl Debug for CemSession
Source§impl Session for CemSession
impl Session for CemSession
Source§fn handle_text(&mut self, text: &str, now: Timestamp) -> Inbound
fn handle_text(&mut self, text: &str, now: Timestamp) -> Inbound
Source§fn handle_message(&mut self, message: Message, now: Timestamp) -> Inbound
fn handle_message(&mut self, message: Message, now: Timestamp) -> Inbound
Source§fn handle_timeout(&mut self, now: Timestamp)
fn handle_timeout(&mut self, now: Timestamp)
Self::poll_timeout.