Skip to main content

Session

Struct Session 

Source
pub struct Session<S> { /* private fields */ }
Expand description

An established binary session. Construction completes both offers and both acceptance bytes before application operations may be sent or received.

Implementations§

Source§

impl<S: Read + Write> Session<S>

Source

pub fn connect(io: S, offer: &Hello) -> Result<Self>

Connect on an explicitly advertised v2 endpoint. The caller sets a single establishment deadline and verifies the peer before sending the offer.

Source

pub fn accept(io: S, offer: &Hello) -> Result<Self>

Admit a connection on the separate v2 listener, after authenticating its OS peer. No request is dispatched if either peer rejects the negotiation.

Source

pub fn refuse(io: S, offer: &Hello, reason: Refused) -> Result<()>

Read a client’s offer and refuse it for reason, then close the connection. Use it for a peer the policy rejected, or while retiring. A client that does not read refusals, or that names another service, sees only the close, as from an older server.

Source

pub fn transport_mut(&mut self) -> &mut S

Access the transport to change I/O deadlines after establishment. Do not read or write protocol bytes through this reference.

Source

pub fn agreement(&self) -> Agreement

Negotiated version, capabilities and frame bound.

Source

pub fn send(&mut self, message: &Control) -> Result<()>

Send a negotiated operation. An I/O failure has an uncertain outcome; reconnecting must not replay it automatically.

Source

pub fn receive(&mut self) -> Result<Control>

Receive a negotiated operation. Unknown operations terminate the session; unknown optional fields within known operations remain compatible.

Auto Trait Implementations§

§

impl<S> Freeze for Session<S>
where Framed<S>: Freeze,

§

impl<S> RefUnwindSafe for Session<S>

§

impl<S> Send for Session<S>
where Framed<S>: Send,

§

impl<S> Sync for Session<S>
where Framed<S>: Sync,

§

impl<S> Unpin for Session<S>
where Framed<S>: Unpin,

§

impl<S> UnsafeUnpin for Session<S>
where Framed<S>: UnsafeUnpin,

§

impl<S> UnwindSafe for Session<S>
where Framed<S>: UnwindSafe,

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.