AsyncWriteSendStreamExtra

Trait AsyncWriteSendStreamExtra 

Source
pub trait AsyncWriteSendStreamExtra: Send {
    // Required methods
    fn inner(&mut self) -> &mut (impl AsyncWrite + Unpin + Send);
    fn reset(&mut self, code: VarInt) -> Result<()>;
    fn stopped(&mut self) -> impl Future<Output = Result<Option<VarInt>>> + Send;
    fn id(&self) -> u64;
}
Expand description

This is a helper trait to work with AsyncWriteSendStream.

If you have an AsyncWrite + Unpin + Send, you can implement these additional methods and wrap the result in an AsyncWriteSendStream to get a SendStream that writes to the underlying AsyncWrite.

Required Methods§

Source

fn inner(&mut self) -> &mut (impl AsyncWrite + Unpin + Send)

Get a mutable reference to the inner AsyncWrite.

Getting a reference is easier than implementing all methods on AsyncWrite with forwarders to the inner instance.

Source

fn reset(&mut self, code: VarInt) -> Result<()>

Reset the stream with the given error code.

Source

fn stopped(&mut self) -> impl Future<Output = Result<Option<VarInt>>> + Send

Wait for the stream to be stopped, returning the optional error code if it was.

Source

fn id(&self) -> u64

A local unique identifier for the stream.

This allows distinguishing between streams, but once the stream is closed, the id may be reused.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§