[−][src]Struct stream_multiplexer::Multiplexer
Implementations
impl<St, Si> Multiplexer<St, Si> where
St: TryStream + Unpin,
St::Ok: Clone,
Si: Sink<St::Ok> + Unpin,
Si::Error: Debug,
[src]
St: TryStream + Unpin,
St::Ok: Clone,
Si: Sink<St::Ok> + Unpin,
Si::Error: Debug,
pub fn new() -> Self
[src]
Creates a Multiplexer
pub fn add_channel(
&mut self,
channel_id: ChannelId
) -> Result<(), MultiplexerError<Si::Error>>
[src]
&mut self,
channel_id: ChannelId
) -> Result<(), MultiplexerError<Si::Error>>
Adds a channel id to the internal table used for validation checks.
Returns an error if channel
already exists.
pub fn has_channel(&self, channel: ChannelId) -> bool
[src]
Returns true if the channel id exists.
pub fn remove_channel(&mut self, channel: ChannelId) -> bool
[src]
Removes a channel.
Returns true
if found, false
otherwise.
pub async fn send<'_>(
&'_ self,
stream_ids: impl IntoIterator<Item = StreamId>,
data: St::Ok
) -> Vec<Result<StreamId, MultiplexerError<Si::Error>>>
[src]
&'_ self,
stream_ids: impl IntoIterator<Item = StreamId>,
data: St::Ok
) -> Vec<Result<StreamId, MultiplexerError<Si::Error>>>
Sends data
to a set of stream_ids
, waiting for them to be sent.
pub fn add_stream_pair(
&mut self,
sink: Si,
stream: St,
channel_id: ChannelId
) -> Result<StreamId, MultiplexerError<Si::Error>>
[src]
&mut self,
sink: Si,
stream: St,
channel_id: ChannelId
) -> Result<StreamId, MultiplexerError<Si::Error>>
Adds stream
to the channel
and stores sink
.
Returns a StreamId
that represents the pair. It can be used in functions such as send()
or change_stream_channel()
.
pub fn change_stream_channel(
&self,
stream_id: StreamId,
channel_id: ChannelId
) -> Result<(), MultiplexerError<Si::Error>>
[src]
&self,
stream_id: StreamId,
channel_id: ChannelId
) -> Result<(), MultiplexerError<Si::Error>>
Signals to the stream that it should move to a given channel.
The channel change is not instantaneous. Calling .recv()
on the stream's current channel
may result in that channel receiving more of the stream's data.
pub fn remove_stream(&mut self, stream_id: StreamId) -> bool
[src]
Removes the stream from the multiplexer
pub async fn recv<'_>(
&'_ mut self,
channel_id: ChannelId
) -> Result<(StreamId, Option<St::Item>), MultiplexerError<Si::Error>>
[src]
&'_ mut self,
channel_id: ChannelId
) -> Result<(StreamId, Option<St::Item>), MultiplexerError<Si::Error>>
Receives the next packet available from a channel:
Returns a tuple of the stream's ID and it's data or an error.
Trait Implementations
impl<St, Si> Clone for Multiplexer<St, Si>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<St: Debug, Si: Debug> Debug for Multiplexer<St, Si> where
St: 'static,
[src]
St: 'static,
Auto Trait Implementations
impl<St, Si> !RefUnwindSafe for Multiplexer<St, Si>
impl<St, Si> Send for Multiplexer<St, Si> where
Si: Send,
St: Send,
Si: Send,
St: Send,
impl<St, Si> Sync for Multiplexer<St, Si> where
Si: Send,
St: Send,
Si: Send,
St: Send,
impl<St, Si> Unpin for Multiplexer<St, Si>
impl<St, Si> !UnwindSafe for Multiplexer<St, Si>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,