pub struct ClientMux {
pub downgraded: bool,
pub supported_extension_ids: Vec<u8>,
/* private fields */
}
Expand description
Client side multiplexor.
§Example
use wisp_mux::{ClientMux, StreamType};
let (mux, fut) = ClientMux::new(rx, tx, Some([])).await?;
tokio::spawn(async move {
if let Err(e) = fut.await {
println!("error in multiplexor: {:?}", e);
}
});
let stream = mux.client_new_stream(StreamType::Tcp, "google.com", 80);
Fields§
§downgraded: bool
Whether the connection was downgraded to Wisp v1.
If this variable is true you must assume no extensions are supported.
supported_extension_ids: Vec<u8>
Extensions that are supported by both sides.
Implementations§
source§impl ClientMux
impl ClientMux
sourcepub async fn create<R, W>(
read: R,
write: W,
extension_builders: Option<&[Box<dyn ProtocolExtensionBuilder + Send + Sync>]>
) -> Result<ClientMuxResult<impl Future<Output = Result<(), WispError>> + Send>, WispError>
pub async fn create<R, W>( read: R, write: W, extension_builders: Option<&[Box<dyn ProtocolExtensionBuilder + Send + Sync>]> ) -> Result<ClientMuxResult<impl Future<Output = Result<(), WispError>> + Send>, WispError>
Create a new client side multiplexor.
If extension_builders
is None a Wisp v1 connection is created otherwise a Wisp v2 connection is created.
It is not guaranteed that all extensions you specify are available. You must manually check
if the extensions you need are available after the multiplexor has been created.
sourcepub async fn client_new_stream(
&self,
stream_type: StreamType,
host: String,
port: u16
) -> Result<MuxStream, WispError>
pub async fn client_new_stream( &self, stream_type: StreamType, host: String, port: u16 ) -> Result<MuxStream, WispError>
Create a new stream, multiplexed through Wisp.
sourcepub async fn close(&self) -> Result<(), WispError>
pub async fn close(&self) -> Result<(), WispError>
Close all streams.
Also terminates the multiplexor future.
sourcepub async fn close_extension_incompat(&self) -> Result<(), WispError>
pub async fn close_extension_incompat(&self) -> Result<(), WispError>
Close all streams and send an extension incompatibility error to the client.
Also terminates the multiplexor future.
sourcepub fn get_protocol_extension_stream(&self) -> MuxProtocolExtensionStream
pub fn get_protocol_extension_stream(&self) -> MuxProtocolExtensionStream
Get a protocol extension stream for sending packets with stream id 0.