Struct turbulence::packet_multiplexer::PacketMultiplexer
source · [−]pub struct PacketMultiplexer<P> { /* private fields */ }
Expand description
Routes packets marked with a channel header from a single Sink
/ Stream
pair to a set of
Sink
/ Stream
pairs for each channel.
Also monitors bandwidth on each channel independently, and returns a ChannelStatistics
handle
to query bandwidth totals for that specific channel.
Implementations
sourceimpl<P> PacketMultiplexer<P> where
P: Packet + Unpin,
impl<P> PacketMultiplexer<P> where
P: Packet + Unpin,
pub fn new() -> PacketMultiplexer<P>
sourcepub fn open_channel(
&mut self,
channel: PacketChannel,
buffer_size: usize
) -> Result<(Sender<MuxPacket<P>>, Receiver<MuxPacket<P>>, ChannelStatistics), DuplicateChannel>
pub fn open_channel(
&mut self,
channel: PacketChannel,
buffer_size: usize
) -> Result<(Sender<MuxPacket<P>>, Receiver<MuxPacket<P>>, ChannelStatistics), DuplicateChannel>
Open a multiplexed packet channel, producing a sender for outgoing MuxPacket
s on this
channel, and a receiver for incoming MuxPacket
s on this channel.
The buffer_size
parameter controls the buffer size requested when creating the MPSC
futures channels for the returned Sender
and Receiver
.
sourcepub fn start(
self
) -> (IncomingMultiplexedPackets<P>, OutgoingMultiplexedPackets<P>)
pub fn start(
self
) -> (IncomingMultiplexedPackets<P>, OutgoingMultiplexedPackets<P>)
Start multiplexing packets to all opened channels.
Returns an IncomingMultiplexedPackets
which is a Sink
for incoming packets, and an
OutgoingMultiplexedPackets
which is a Stream
for outgoing packets.
Auto Trait Implementations
impl<P> !RefUnwindSafe for PacketMultiplexer<P>
impl<P> Send for PacketMultiplexer<P> where
P: Send,
impl<P> Sync for PacketMultiplexer<P> where
P: Send,
impl<P> Unpin for PacketMultiplexer<P>
impl<P> !UnwindSafe for PacketMultiplexer<P>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more