pub struct AgentSession { /* private fields */ }Expand description
The device agent’s end of the connection.
Implementations§
Source§impl AgentSession
impl AgentSession
Sourcepub fn new(config: AgentConfig, now: Instant) -> AgentSession
pub fn new(config: AgentConfig, now: Instant) -> AgentSession
Starts the session; the hello is ready to send at once, and the welcome must arrive within the peer timeout.
Sourcepub fn receive_eof(&mut self, now: Instant)
pub fn receive_eof(&mut self, now: Instant)
The connection reached its end.
Sourcepub fn handle_timeout(&mut self, now: Instant)
pub fn handle_timeout(&mut self, now: Instant)
Answers requests whose deadline passed and keeps the connection alive.
Sourcepub fn poll_timeout(&self) -> Option<Instant>
pub fn poll_timeout(&self) -> Option<Instant>
When handle_timeout must next run; None once closed.
Sourcepub fn deadline(&self, id: u32) -> Option<Instant>
pub fn deadline(&self, id: u32) -> Option<Instant>
The instant request id must be answered by, if it has a deadline.
Sourcepub fn respond(&mut self, id: u32, result: Result<Reply, Error>) -> Responded
pub fn respond(&mut self, id: u32, result: Result<Reply, Error>) -> Responded
Answers request id.
Sourcepub fn emit(&mut self, payload: EventPayload, time_us: u64) -> Option<u64>
pub fn emit(&mut self, payload: EventPayload, time_us: u64) -> Option<u64>
Sends an event on its payload’s stream with the stream’s next sequence
number and returns the number. None when the session is not ready,
or when the event exceeds the negotiated frame size; its number is
used up then, so the host sees the gap and asks for a resync.
Sourcepub fn skip_event(&mut self, stream: Stream) -> Option<u64>
pub fn skip_event(&mut self, stream: Stream) -> Option<u64>
Uses up the next sequence number of stream without sending an event,
as when a full event queue drops one. The host sees the gap: a
lossless stream then asks for a resync, a lossy one counts a drop.
Sourcepub fn last_seq(&self, stream: Stream) -> u64
pub fn last_seq(&self, stream: Stream) -> u64
The last sequence number sent or skipped on stream; 0 before the first.
Sourcepub fn poll_transmit(&mut self) -> Option<Vec<u8>>
pub fn poll_transmit(&mut self) -> Option<Vec<u8>>
Bytes to write to the connection.
pub fn poll_event(&mut self) -> Option<AgentEvent>
pub fn is_closed(&self) -> bool
Sourcepub fn close_reason(&self) -> Option<&DisconnectReason>
pub fn close_reason(&self) -> Option<&DisconnectReason>
Why the session closed, once it has.