Trait async_proto::Protocol[][src]

pub trait Protocol: Sized {
    fn read<'a, R: AsyncRead + Unpin + Send + 'a>(
        stream: &'a mut R
    ) -> Pin<Box<dyn Future<Output = Result<Self, ReadError>> + Send + 'a>>;
fn write<'a, W: AsyncWrite + Unpin + Send + 'a>(
        &'a self,
        sink: &'a mut W
    ) -> Pin<Box<dyn Future<Output = Result<(), WriteError>> + Send + 'a>>;
fn read_sync(stream: &mut impl Read) -> Result<Self, ReadError>;
fn write_sync(&self, sink: &mut impl Write) -> Result<(), WriteError>; fn read_ws<'a, R: Stream<Item = Result<Message, Error>> + Unpin + Send + 'a>(
        stream: &'a mut R
    ) -> Pin<Box<dyn Future<Output = Result<Self, ReadError>> + Send + 'a>> { ... }
fn write_ws<'a, W: Sink<Message, Error = Error> + Unpin + Send + 'a>(
        &'a self,
        sink: &'a mut W
    ) -> Pin<Box<dyn Future<Output = Result<(), WriteError>> + Send + 'a>>
    where
        Self: Sync
, { ... }
fn read_warp<'a, R: Stream<Item = Result<Message, Error>> + Unpin + Send + 'a>(
        stream: &'a mut R
    ) -> Pin<Box<dyn Future<Output = Result<Self, ReadError>> + Send + 'a>> { ... }
fn write_warp<'a, W: Sink<Message, Error = Error> + Unpin + Send + 'a>(
        &'a self,
        sink: &'a mut W
    ) -> Pin<Box<dyn Future<Output = Result<(), WriteError>> + Send + 'a>>
    where
        Self: Sync
, { ... } }
Expand description

This trait allows reading a value of an implementing type from an async or sync stream, as well as writing one to an async or sync sink.

Required methods

Reads a value of this type from an async stream.

Writes a value of this type to an async sink.

Reads a value of this type from a sync stream.

Writes a value of this type to a sync sink.

Provided methods

Reads a value of this type from a tokio-tungstenite websocket.

Writes a value of this type to a tokio-tungstenite websocket.

Reads a value of this type from a warp websocket.

Writes a value of this type to a warp websocket.

Implementations on Foreign Types

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Primitive number types are encoded in big-endian format.

Represented as one byte, with 0 for false and 1 for true.

A vector is prefixed with the length as a u64.

A set is prefixed with the length as a u64.

A set is prefixed with the length as a u64.

A string is encoded in UTF-8 and prefixed with the length as a u64.

A map is prefixed with the length as a u64.

A map is prefixed with the length as a u64.

A cow is represented like its owned variant.

Note that due to a restriction in the type system, writing a borrowed cow requires cloning it.

A nonzero integer is represented like its value.

A nonzero integer is represented like its value.

A nonzero integer is represented like its value.

A nonzero integer is represented like its value.

A nonzero integer is represented like its value.

A nonzero integer is represented like its value.

A nonzero integer is represented like its value.

A nonzero integer is represented like its value.

A nonzero integer is represented like its value.

A nonzero integer is represented like its value.

A duration is represented as the number of whole seconds as a u64 followed by the number of subsecond nanoseconds as a u32.

Implementors