pub struct Multiplexer<St, Si>where
St: 'static,{ /* private fields */ }Expand description
Implementations§
Source§impl<St, Si> Multiplexer<St, Si>
impl<St, Si> Multiplexer<St, Si>
Sourcepub fn add_channel(
&mut self,
channel_id: ChannelId,
) -> Result<(), MultiplexerError<Si::Error>>
pub fn add_channel( &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.
Sourcepub fn has_channel(&self, channel: ChannelId) -> bool
pub fn has_channel(&self, channel: ChannelId) -> bool
Returns true if the channel id exists.
Sourcepub fn remove_channel(&mut self, channel: ChannelId) -> bool
pub fn remove_channel(&mut self, channel: ChannelId) -> bool
Removes a channel.
Returns true if found, false otherwise.
Sourcepub async fn send(
&self,
stream_ids: impl IntoIterator<Item = StreamId>,
data: St::Ok,
) -> Vec<Result<StreamId, MultiplexerError<Si::Error>>>
pub async fn send( &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.
Sourcepub fn add_stream_pair(
&mut self,
sink: Si,
stream: St,
channel_id: ChannelId,
) -> Result<StreamId, MultiplexerError<Si::Error>>
pub fn add_stream_pair( &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().
Sourcepub fn change_stream_channel(
&self,
stream_id: StreamId,
channel_id: ChannelId,
) -> Result<(), MultiplexerError<Si::Error>>
pub fn change_stream_channel( &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.
Sourcepub fn remove_stream(&mut self, stream_id: StreamId) -> bool
pub fn remove_stream(&mut self, stream_id: StreamId) -> bool
Removes the stream from the multiplexer
Trait Implementations§
Source§impl<St, Si> Clone for Multiplexer<St, Si>
impl<St, Si> Clone for Multiplexer<St, Si>
Auto Trait Implementations§
impl<St, Si> Freeze for Multiplexer<St, Si>
impl<St, Si> !RefUnwindSafe for Multiplexer<St, Si>
impl<St, Si> Send for Multiplexer<St, Si>
impl<St, Si> Sync for Multiplexer<St, Si>
impl<St, Si> Unpin for Multiplexer<St, Si>
impl<St, Si> UnsafeUnpin for Multiplexer<St, Si>
impl<St, Si> !UnwindSafe for Multiplexer<St, Si>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more