Skip to main content

AgentSession

Struct AgentSession 

Source
pub struct AgentSession { /* private fields */ }
Expand description

The device agent’s end of the connection.

Implementations§

Source§

impl AgentSession

Source

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.

Source

pub fn receive(&mut self, bytes: &[u8], now: Instant)

Feeds bytes read from the connection.

Source

pub fn receive_eof(&mut self, now: Instant)

The connection reached its end.

Source

pub fn handle_timeout(&mut self, now: Instant)

Answers requests whose deadline passed and keeps the connection alive.

Source

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

When handle_timeout must next run; None once closed.

Source

pub fn deadline(&self, id: u32) -> Option<Instant>

The instant request id must be answered by, if it has a deadline.

Source

pub fn respond(&mut self, id: u32, result: Result<Reply, Error>) -> Responded

Answers request id.

Source

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.

Source

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.

Source

pub fn last_seq(&self, stream: Stream) -> u64

The last sequence number sent or skipped on stream; 0 before the first.

Source

pub fn poll_transmit(&mut self) -> Option<Vec<u8>>

Bytes to write to the connection.

Source

pub fn poll_event(&mut self) -> Option<AgentEvent>

Source

pub fn is_closed(&self) -> bool

Source

pub fn close_reason(&self) -> Option<&DisconnectReason>

Why the session closed, once it has.

Trait Implementations§

Source§

impl Debug for AgentSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.