Struct IncomingMultiChannel

Source
pub struct IncomingMultiChannel<P, R> { /* private fields */ }
Expand description

An IncomingMultiChannel is established for each incoming TCP connection. The local party will act as the server for the remote client.

The demux part takes messages from the incoming connection and dispatches to the implementing protocols. If the protocol doesn’t exist, a server session is instantiated to handle the messages.

The mux part listens for outgoing messages from all instantiated server sessions, relaying responses to the client.

Implementations§

Source§

impl<P: Ord + Copy + Debug, R> IncomingMultiChannel<P, R>

Source

pub fn new( tx: Sender<MultiMessage<P, R>>, rx: Receiver<MultiMessage<P, R>>, ) -> Self

Create a new MultiChannel by passing it the channels it can use to send/receive messages to/from the underlying network connection.

Source

pub async fn run<F>(self, init_server: F)
where F: FnMut(P, Sender<SessionError>) -> (Sender<R>, Receiver<R>),

Start consuming messages from the client, creating new protocol handlers where one doesn’t exist already.

We must also listen to an internal channel that signals the abortion of the whole connection due to some protocol violation.

init_server should initiate the server side of the protocol, listening to incoming messages from the client; it should return the channels we can send the client messages to, and receive the replies over. When sending or receiving from these channels fail, the protocol is over and should be removed.

Auto Trait Implementations§

§

impl<P, R> Freeze for IncomingMultiChannel<P, R>

§

impl<P, R> RefUnwindSafe for IncomingMultiChannel<P, R>
where P: RefUnwindSafe,

§

impl<P, R> Send for IncomingMultiChannel<P, R>
where P: Send, R: Send,

§

impl<P, R> Sync for IncomingMultiChannel<P, R>
where P: Sync + Send, R: Send,

§

impl<P, R> Unpin for IncomingMultiChannel<P, R>

§

impl<P, R> UnwindSafe for IncomingMultiChannel<P, R>
where P: RefUnwindSafe,

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.