pub struct ServerMux<W>where
W: WebSocketWrite + Send + 'static,{ /* private fields */ }
Expand description
Server-side multiplexor.
§Example
use wisp_mux::ServerMux;
let (mux, fut) = ServerMux::new(rx, tx, 128);
tokio::spawn(async move {
if let Err(e) = fut.await {
println!("error in multiplexor: {:?}", e);
}
});
while let Some((packet, stream)) = mux.server_new_stream().await {
tokio::spawn(async move {
let url = format!("{}:{}", packet.destination_hostname, packet.destination_port);
// do something with `url` and `packet.stream_type`
});
}
Implementations§
source§impl<W: WebSocketWrite + Send + 'static> ServerMux<W>
impl<W: WebSocketWrite + Send + 'static> ServerMux<W>
sourcepub fn new<R>(
read: R,
write: W,
buffer_size: u32
) -> (Self, impl Future<Output = Result<(), WispError>>)where
R: WebSocketRead,
pub fn new<R>(
read: R,
write: W,
buffer_size: u32
) -> (Self, impl Future<Output = Result<(), WispError>>)where
R: WebSocketRead,
Create a new server-side multiplexor.
sourcepub async fn server_new_stream(
&mut self
) -> Option<(ConnectPacket, MuxStream<W>)>
pub async fn server_new_stream( &mut self ) -> Option<(ConnectPacket, MuxStream<W>)>
Wait for a stream to be created.
Auto Trait Implementations§
impl<W> !RefUnwindSafe for ServerMux<W>
impl<W> Send for ServerMux<W>
impl<W> Sync for ServerMux<W>
impl<W> Unpin for ServerMux<W>
impl<W> !UnwindSafe for ServerMux<W>
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