pub struct ServerMux { /* 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 ServerMux
impl ServerMux
sourcepub fn new<R, W: WebSocketWrite>(
read: R,
write: W,
buffer_size: u32
) -> (Self, impl Future<Output = Result<(), WispError>>)where
R: WebSocketRead,
pub fn new<R, W: WebSocketWrite>(
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)>
pub async fn server_new_stream(&mut self) -> Option<(ConnectPacket, MuxStream)>
Wait for a stream to be created.
Auto Trait Implementations§
impl Freeze for ServerMux
impl !RefUnwindSafe for ServerMux
impl Send for ServerMux
impl Sync for ServerMux
impl Unpin for ServerMux
impl !UnwindSafe for ServerMux
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