Trait async_proto::Protocol
source · [−]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 try_read(
stream: &mut impl Read,
buf: &mut Vec<u8>
) -> Result<Option<Self>, ReadError> { ... }
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.
Cancellation safety
Implementations of this method are generally not cancellation safe.
Writes a value of this type to an async sink.
Cancellation safety
Implementations of this method are generally not cancellation safe.
read-sync
only.Reads a value of this type from a sync stream.
fn write_sync(&self, sink: &mut impl Write) -> Result<(), WriteError>
fn write_sync(&self, sink: &mut impl Write) -> Result<(), WriteError>
write-sync
only.Writes a value of this type to a sync sink.
Provided methods
read-sync
only.Attempts to read a value of this type from a prefix in a buffer and a suffix in a sync stream.
If io::ErrorKind::WouldBlock
is encountered, Ok(None)
is returned and the portion read successfully is appended to buf
. Otherwise, the prefix representing the returned value is removed from buf
.
Callers, not implementations, should ensure that stream
is non-blocking if desired.
Example
use {
std::net::TcpStream,
async_proto::Protocol,
};
struct Client {
tcp_stream: TcpStream,
buf: Vec<u8>,
}
impl Client {
fn new(tcp_stream: TcpStream) -> Self {
Self {
tcp_stream,
buf: Vec::default(),
}
}
fn try_read<T: Protocol>(&mut self) -> Result<Option<T>, async_proto::ReadError> {
self.tcp_stream.set_nonblocking(true)?;
T::try_read(&mut self.tcp_stream, &mut self.buf)
}
fn write<T: Protocol>(&mut self, msg: &T) -> Result<(), async_proto::WriteError> {
self.tcp_stream.set_nonblocking(false)?;
msg.write_sync(&mut self.tcp_stream)
}
}
tokio-tungstenite
only.Reads a value of this type from a tokio-tungstenite
websocket.
Cancellation safety
The default implementation of this method is cancellation safe if and only if the read-sync
feature is enabled.
tokio-tungstenite
only.Writes a value of this type to a tokio-tungstenite
websocket.
Cancellation safety
The default implementation of this method is not cancellation safe.
warp
only.Reads a value of this type from a warp
websocket.
Cancellation safety
The default implementation of this method is cancellation safe if and only if the read-sync
feature is enabled.
warp
only.Writes a value of this type to a warp
websocket.
Cancellation safety
The default implementation of this method is not cancellation safe.
Implementations on Foreign Types
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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.A timezone is represented as an IANA timezone identifier.
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>>
read-sync
only.write-sync
only.impl<F: Float, C: FloatChecker<F>> Protocol for NoisyFloat<F, C> where
F: Protocol + Float + Send + Sync + 'static,
C: FloatChecker<F> + Send + Sync,
This is supported on crate feature noisy_float
only.
impl<F: Float, C: FloatChecker<F>> Protocol for NoisyFloat<F, C> where
F: Protocol + Float + Send + Sync + 'static,
C: FloatChecker<F> + Send + Sync,
noisy_float
only.A noisy float is represented like its underlying type. Reading an invalid float produces a ReadError::Custom
.
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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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)
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)
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>>
read-sync
only.write-sync
only.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)
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)
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>>
read-sync
only.write-sync
only.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)
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)
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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.Represented as one byte, with 0
for false
and 1
for true
.
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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.A vector is prefixed with the length as a u64
.
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>>
read-sync
only.write-sync
only.A set is prefixed with the length as a u64
.
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>>
read-sync
only.write-sync
only.A set is prefixed with the length as a u64
.
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>>
read-sync
only.write-sync
only.A string is encoded in UTF-8 and prefixed with the length in bytes as a u64
.
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>>
read-sync
only.write-sync
only.A map is prefixed with the length as a u64
.
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>>
read-sync
only.write-sync
only.A map is prefixed with the length as a u64
.
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>>
read-sync
only.write-sync
only.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.
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>>
read-sync
only.write-sync
only.A nonzero integer is represented like its value.
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>>
read-sync
only.write-sync
only.A nonzero integer is represented like its value.
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>>
read-sync
only.write-sync
only.A nonzero integer is represented like its value.
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>>
read-sync
only.write-sync
only.A nonzero integer is represented like its value.
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>>
read-sync
only.write-sync
only.A nonzero integer is represented like its value.
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>>
read-sync
only.write-sync
only.A nonzero integer is represented like its value.
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>>
read-sync
only.write-sync
only.A nonzero integer is represented like its value.
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>>
read-sync
only.write-sync
only.A nonzero integer is represented like its value.
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>>
read-sync
only.write-sync
only.A nonzero integer is represented like its value.
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>>
read-sync
only.write-sync
only.A nonzero integer is represented like its value.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.Primitive number types are encoded in big-endian format.
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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.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>>
read-sync
only.write-sync
only.A duration is represented as the number of whole seconds as a u64
followed by the number of subsecond nanoseconds as a u32
.
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>>
read-sync
only.write-sync
only.