Struct wisp_mux::MuxStreamWrite
source · pub struct MuxStreamWrite {
pub stream_id: u32,
pub stream_type: StreamType,
/* private fields */
}
Expand description
Write side of a multiplexor stream.
Fields§
§stream_id: u32
ID of the stream.
stream_type: StreamType
Type of the stream.
Implementations§
source§impl MuxStreamWrite
impl MuxStreamWrite
sourcepub async fn write_payload(&self, data: Payload<'_>) -> Result<(), WispError>
pub async fn write_payload(&self, data: Payload<'_>) -> Result<(), WispError>
Write a payload to the stream.
sourcepub async fn write<D: AsRef<[u8]>>(&self, data: D) -> Result<(), WispError>
pub async fn write<D: AsRef<[u8]>>(&self, data: D) -> Result<(), WispError>
Write data to the stream.
sourcepub fn get_close_handle(&self) -> MuxStreamCloser
pub fn get_close_handle(&self) -> MuxStreamCloser
Get a handle to close the connection.
Useful to close the connection without having access to the stream.
§Example
let handle = stream.get_close_handle();
if let Err(error) = handle_stream(stream) {
handle.close(0x01);
}
sourcepub fn get_protocol_extension_stream(&self) -> MuxProtocolExtensionStream
pub fn get_protocol_extension_stream(&self) -> MuxProtocolExtensionStream
Get a protocol extension stream to send protocol extension packets.
sourcepub async fn close(&self, reason: CloseReason) -> Result<(), WispError>
pub async fn close(&self, reason: CloseReason) -> Result<(), WispError>
Close the stream. You will no longer be able to write or read after this has been called.
sourcepub fn get_close_reason(&self) -> Option<CloseReason>
pub fn get_close_reason(&self) -> Option<CloseReason>
Get the stream’s close reason, if it was closed.
sourcepub fn into_sink(self) -> MuxStreamIoSink
pub fn into_sink(self) -> MuxStreamIoSink
Turn the write half into one that implements futures Sink
, consuming it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MuxStreamWrite
impl !RefUnwindSafe for MuxStreamWrite
impl Send for MuxStreamWrite
impl Sync for MuxStreamWrite
impl Unpin for MuxStreamWrite
impl !UnwindSafe for MuxStreamWrite
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