Struct Stream

Source
pub struct Stream<P: Protocol> { /* private fields */ }
Expand description

A main stream state machine abstaction

You may use the Stream directly. But it’s recommented to either use Persistent for client connections or Accept for server-side connection processing.

Implementations§

Source§

impl<P: Protocol> Stream<P>

Source

pub fn transport(&mut self) -> Transport<'_, P::Socket>

Get a Transport object for the stream

This method is only useful if you want to manipulate buffers externally (like pushing to the buffer from another thread). Just be sure to wake up state machine after manipulating buffers.

Source

pub fn new( sock: P::Socket, seed: P::Seed, scope: &mut Scope<'_, P::Context>, ) -> Response<Self, Void>

Source

pub fn connected( sock: P::Socket, seed: P::Seed, scope: &mut Scope<'_, P::Context>, ) -> Response<Self, Void>

Trait Implementations§

Source§

impl<P: Protocol> Accepted for Stream<P>
where <P as Protocol>::Seed: Clone,

Source§

type Seed = <P as Protocol>::Seed

Source§

type Socket = <P as Protocol>::Socket

Source§

fn accepted( sock: P::Socket, seed: <P as Protocol>::Seed, scope: &mut Scope<'_, Self::Context>, ) -> Response<Self, Void>

The constructor of the state machine from the accepted connection
Source§

impl<P: Debug + Protocol> Debug for Stream<P>
where P::Socket: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<P: Protocol> Machine for Stream<P>

Source§

type Context = <P as Protocol>::Context

Context type for the state machine Read more
Source§

type Seed = Void

Seed is piece of data that is needed to initialize the machine Read more
Source§

fn create( void: Void, _scope: &mut Scope<'_, Self::Context>, ) -> Response<Self, Void>

Create a machine from some data Read more
Source§

fn ready( self, events: EventSet, scope: &mut Scope<'_, Self::Context>, ) -> Response<Self, Self::Seed>

Socket readiness notification
Source§

fn spawned( self, _scope: &mut Scope<'_, Self::Context>, ) -> Response<Self, Self::Seed>

Called after spawn event Read more
Source§

fn timeout( self, scope: &mut Scope<'_, Self::Context>, ) -> Response<Self, Self::Seed>

Timeout happened
Source§

fn wakeup( self, scope: &mut Scope<'_, Self::Context>, ) -> Response<Self, Self::Seed>

Message received Read more
Source§

fn spawn_error( self, _scope: &mut Scope<'_, Self::Context>, error: SpawnError<Self::Seed>, ) -> Response<Self, Self::Seed>

Called instead of spawned, if there is no slab space Read more

Auto Trait Implementations§

§

impl<P> Freeze for Stream<P>
where <P as Protocol>::Socket: Freeze, P: Freeze,

§

impl<P> RefUnwindSafe for Stream<P>

§

impl<P> Send for Stream<P>
where <P as Protocol>::Socket: Send, P: Send,

§

impl<P> Sync for Stream<P>
where <P as Protocol>::Socket: Sync, P: Sync,

§

impl<P> Unpin for Stream<P>
where <P as Protocol>::Socket: Unpin, P: Unpin,

§

impl<P> UnwindSafe for Stream<P>
where <P as Protocol>::Socket: UnwindSafe, P: 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.