pub struct StreamMultiplexor<T> { /* private fields */ }
Expand description
The Stream Multiplexor.
Implementations§
Source§impl<T: AsyncRead + AsyncWrite + Send + Unpin + 'static> StreamMultiplexor<T>
impl<T: AsyncRead + AsyncWrite + Send + Unpin + 'static> StreamMultiplexor<T>
Sourcepub fn new(inner: T, config: StreamMultiplexorConfig) -> Self
pub fn new(inner: T, config: StreamMultiplexorConfig) -> Self
Constructs a new StreamMultiplexor<T>
.
Sourcepub fn new_paused(inner: T, config: StreamMultiplexorConfig) -> Self
pub fn new_paused(inner: T, config: StreamMultiplexorConfig) -> Self
Constructs a new paused StreamMultiplexor<T>
.
This allows you to bind and listen on a bunch of ports before
processing any packets from the inner stream, removing race conditions
between bind and connect. Call start()
to start processing the
inner stream.
Sourcepub fn start(&self)
pub fn start(&self)
Start processing the inner stream.
Only effective on a paused StreamMultiplexor<T>
.
See new_paused(inner: T, config: StreamMultiplexorConfig)
.
Sourcepub fn close(&self)
pub fn close(&self)
Shut down the StreamMultiplexor
Sourcepub async fn bind(&self, port: u16) -> Result<MuxListener<T>>
pub async fn bind(&self, port: u16) -> Result<MuxListener<T>>
Bind to port and return a MuxListener<T>
.
Sourcepub async fn connect(&self, port: u16) -> Result<DuplexStream>
pub async fn connect(&self, port: u16) -> Result<DuplexStream>
Connect to port
on the remote end.
Sourcepub fn watch_connected(&self) -> Receiver<bool>
pub fn watch_connected(&self) -> Receiver<bool>
Return a tokio::sync::watch::Receiver
that will update to false
when the inner stream closes.
Trait Implementations§
Source§impl<T> Debug for StreamMultiplexor<T>
impl<T> Debug for StreamMultiplexor<T>
Auto Trait Implementations§
impl<T> Freeze for StreamMultiplexor<T>
impl<T> !RefUnwindSafe for StreamMultiplexor<T>
impl<T> Send for StreamMultiplexor<T>
impl<T> Sync for StreamMultiplexor<T>
impl<T> Unpin for StreamMultiplexor<T>
impl<T> !UnwindSafe for StreamMultiplexor<T>
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