[][src]Trait async_proto::Protocol

pub trait Protocol: Sized {
    type ReadError;
    pub fn read<'a, R: AsyncRead + Unpin + Send + 'a>(
        stream: R
    ) -> Pin<Box<dyn Future<Output = Result<Self, Self::ReadError>> + Send + 'a>>;
pub fn write<'a, W: AsyncWrite + Unpin + Send + 'a>(
        &'a self,
        sink: W
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
pub fn read_sync<'a>(
        stream: impl Read + 'a
    ) -> Result<Self, Self::ReadError>;
pub fn write_sync<'a>(&self, sink: impl Write + 'a) -> Result<()>; }

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.

Associated Types

type ReadError[src]

The error returned from the read and read_sync methods.

It can be an io::Error or an error representing malformed data.

Loading content...

Required methods

pub fn read<'a, R: AsyncRead + Unpin + Send + 'a>(
    stream: R
) -> Pin<Box<dyn Future<Output = Result<Self, Self::ReadError>> + Send + 'a>>
[src]

Reads a value of this type from an async stream.

pub fn write<'a, W: AsyncWrite + Unpin + Send + 'a>(
    &'a self,
    sink: W
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>
[src]

Writes a value of this type to an async sink.

pub fn read_sync<'a>(stream: impl Read + 'a) -> Result<Self, Self::ReadError>[src]

Reads a value of this type from a sync stream.

pub fn write_sync<'a>(&self, sink: impl Write + 'a) -> Result<()>[src]

Writes a value of this type to a sync sink.

Loading content...

Implementations on Foreign Types

impl Protocol for u8[src]

type ReadError = Error

impl Protocol for i8[src]

type ReadError = Error

impl Protocol for u16[src]

type ReadError = Error

impl Protocol for i16[src]

type ReadError = Error

impl Protocol for u32[src]

type ReadError = Error

impl Protocol for i32[src]

type ReadError = Error

impl Protocol for u64[src]

type ReadError = Error

impl Protocol for i64[src]

type ReadError = Error

impl Protocol for u128[src]

type ReadError = Error

impl Protocol for i128[src]

type ReadError = Error

impl<A: Protocol + Send + Sync> Protocol for (A,) where
    A::ReadError: Send
[src]

type ReadError = Tuple1ReadError<A>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync> Protocol for (A, B) where
    A::ReadError: Send,
    B::ReadError: Send
[src]

type ReadError = Tuple2ReadError<A, B>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync, C: Protocol + Send + Sync> Protocol for (A, B, C) where
    A::ReadError: Send,
    B::ReadError: Send,
    C::ReadError: Send
[src]

type ReadError = Tuple3ReadError<A, B, C>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync, C: Protocol + Send + Sync, D: Protocol + Send + Sync> Protocol for (A, B, C, D) where
    A::ReadError: Send,
    B::ReadError: Send,
    C::ReadError: Send,
    D::ReadError: Send
[src]

type ReadError = Tuple4ReadError<A, B, C, D>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync, C: Protocol + Send + Sync, D: Protocol + Send + Sync, E: Protocol + Send + Sync> Protocol for (A, B, C, D, E) where
    A::ReadError: Send,
    B::ReadError: Send,
    C::ReadError: Send,
    D::ReadError: Send,
    E::ReadError: Send
[src]

type ReadError = Tuple5ReadError<A, B, C, D, E>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync, C: Protocol + Send + Sync, D: Protocol + Send + Sync, E: Protocol + Send + Sync, F: Protocol + Send + Sync> Protocol for (A, B, C, D, E, F) where
    A::ReadError: Send,
    B::ReadError: Send,
    C::ReadError: Send,
    D::ReadError: Send,
    E::ReadError: Send,
    F::ReadError: Send
[src]

type ReadError = Tuple6ReadError<A, B, C, D, E, F>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync, C: Protocol + Send + Sync, D: Protocol + Send + Sync, E: Protocol + Send + Sync, F: Protocol + Send + Sync, G: Protocol + Send + Sync> Protocol for (A, B, C, D, E, F, G) where
    A::ReadError: Send,
    B::ReadError: Send,
    C::ReadError: Send,
    D::ReadError: Send,
    E::ReadError: Send,
    F::ReadError: Send,
    G::ReadError: Send
[src]

type ReadError = Tuple7ReadError<A, B, C, D, E, F, G>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync, C: Protocol + Send + Sync, D: Protocol + Send + Sync, E: Protocol + Send + Sync, F: Protocol + Send + Sync, G: Protocol + Send + Sync, H: Protocol + Send + Sync> Protocol for (A, B, C, D, E, F, G, H) where
    A::ReadError: Send,
    B::ReadError: Send,
    C::ReadError: Send,
    D::ReadError: Send,
    E::ReadError: Send,
    F::ReadError: Send,
    G::ReadError: Send,
    H::ReadError: Send
[src]

type ReadError = Tuple8ReadError<A, B, C, D, E, F, G, H>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync, C: Protocol + Send + Sync, D: Protocol + Send + Sync, E: Protocol + Send + Sync, F: Protocol + Send + Sync, G: Protocol + Send + Sync, H: Protocol + Send + Sync, I: Protocol + Send + Sync> Protocol for (A, B, C, D, E, F, G, H, I) where
    A::ReadError: Send,
    B::ReadError: Send,
    C::ReadError: Send,
    D::ReadError: Send,
    E::ReadError: Send,
    F::ReadError: Send,
    G::ReadError: Send,
    H::ReadError: Send,
    I::ReadError: Send
[src]

type ReadError = Tuple9ReadError<A, B, C, D, E, F, G, H, I>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync, C: Protocol + Send + Sync, D: Protocol + Send + Sync, E: Protocol + Send + Sync, F: Protocol + Send + Sync, G: Protocol + Send + Sync, H: Protocol + Send + Sync, I: Protocol + Send + Sync, J: Protocol + Send + Sync> Protocol for (A, B, C, D, E, F, G, H, I, J) where
    A::ReadError: Send,
    B::ReadError: Send,
    C::ReadError: Send,
    D::ReadError: Send,
    E::ReadError: Send,
    F::ReadError: Send,
    G::ReadError: Send,
    H::ReadError: Send,
    I::ReadError: Send,
    J::ReadError: Send
[src]

type ReadError = Tuple10ReadError<A, B, C, D, E, F, G, H, I, J>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync, C: Protocol + Send + Sync, D: Protocol + Send + Sync, E: Protocol + Send + Sync, F: Protocol + Send + Sync, G: Protocol + Send + Sync, H: Protocol + Send + Sync, I: Protocol + Send + Sync, J: Protocol + Send + Sync, K: Protocol + Send + Sync> Protocol for (A, B, C, D, E, F, G, H, I, J, K) where
    A::ReadError: Send,
    B::ReadError: Send,
    C::ReadError: Send,
    D::ReadError: Send,
    E::ReadError: Send,
    F::ReadError: Send,
    G::ReadError: Send,
    H::ReadError: Send,
    I::ReadError: Send,
    J::ReadError: Send,
    K::ReadError: Send
[src]

type ReadError = Tuple11ReadError<A, B, C, D, E, F, G, H, I, J, K>

impl<A: Protocol + Send + Sync, B: Protocol + Send + Sync, C: Protocol + Send + Sync, D: Protocol + Send + Sync, E: Protocol + Send + Sync, F: Protocol + Send + Sync, G: Protocol + Send + Sync, H: Protocol + Send + Sync, I: Protocol + Send + Sync, J: Protocol + Send + Sync, K: Protocol + Send + Sync, L: Protocol + Send + Sync> Protocol for (A, B, C, D, E, F, G, H, I, J, K, L) where
    A::ReadError: Send,
    B::ReadError: Send,
    C::ReadError: Send,
    D::ReadError: Send,
    E::ReadError: Send,
    F::ReadError: Send,
    G::ReadError: Send,
    H::ReadError: Send,
    I::ReadError: Send,
    J::ReadError: Send,
    K::ReadError: Send,
    L::ReadError: Send
[src]

type ReadError = Tuple12ReadError<A, B, C, D, E, F, G, H, I, J, K, L>

impl Protocol for ()[src]

type ReadError = Never

impl Protocol for bool[src]

type ReadError = BoolReadError

impl<T: Protocol + Sync> Protocol for Option<T>[src]

type ReadError = OptionReadError<T>

impl<T: Protocol + Send + Sync> Protocol for Vec<T>[src]

type ReadError = VecReadError<T>

impl Protocol for String[src]

type ReadError = StringReadError

impl<K: Protocol + Ord + Send + Sync + 'static, V: Protocol + Send + Sync + 'static> Protocol for BTreeMap<K, V> where
    K::ReadError: Send,
    V::ReadError: Send
[src]

type ReadError = MapReadError<K, V>

impl<K: Protocol + Eq + Hash + Send + Sync, V: Protocol + Send + Sync> Protocol for HashMap<K, V> where
    K::ReadError: Send,
    V::ReadError: Send
[src]

type ReadError = MapReadError<K, V>

impl Protocol for Duration[src]

type ReadError = Error

Loading content...

Implementors

Loading content...