Skip to main content

Transformable

Trait Transformable 

Source
pub trait Transformable:
    Send
    + Sync
    + 'static {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>;
    fn encoded_len(&self) -> usize;
    fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
       where Self: Sized;

    // Provided methods
    fn encode_to_vec(&self) -> Result<Vec<u8>, Self::Error> { ... }
    fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize> { ... }
    fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>(
        &self,
        writer: &mut W,
    ) -> impl Future<Output = Result<usize>> + Send { ... }
    fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
       where Self: Sized { ... }
    fn decode_from_async_reader<R: AsyncRead + Send + Unpin>(
        reader: &mut R,
    ) -> impl Future<Output = Result<(usize, Self)>> + Send
       where Self: Sized { ... }
}
Expand description

The type can transform its representation between structured and byte form.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

The error type returned when encoding or decoding fails.

Required Methods§

Source

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Encodes the value into the given buffer for transmission.

Returns the number of bytes written to the buffer.

Source

fn encoded_len(&self) -> usize

Returns the encoded length of the value. This is used to pre-allocate a buffer for encoding.

Source

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Decodes the value from the given buffer received over the wire.

Returns the number of bytes read from the buffer and the struct.

Provided Methods§

Source

fn encode_to_vec(&self) -> Result<Vec<u8>, Self::Error>

Available on crate features alloc or std only.

Encodes the value into a vec for transmission.

Source

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.

Encodes the value into the given writer for transmission.

Source

fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> impl Future<Output = Result<usize>> + Send

Available on crate feature async only.

Encodes the value into the given async writer for transmission.

Source

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.

Decodes the value from the given reader received over the wire.

Returns the number of bytes read from the reader and the struct.

Source

fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> impl Future<Output = Result<(usize, Self)>> + Send
where Self: Sized,

Available on crate feature async only.

Decodes the value from the given async reader received over the wire.

Returns the number of bytes read from the reader and the struct.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Transformable for IpAddr

Available on crate feature std only.
Source§

type Error = IpAddrTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for SocketAddr

Available on crate feature std only.
Source§

type Error = SocketAddrTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for i8

Source§

type Error = NumberTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for i16

Source§

type Error = NumberTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for i32

Source§

type Error = NumberTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for i64

Source§

type Error = NumberTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for i128

Source§

type Error = NumberTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for u8

Source§

type Error = NumberTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for u16

Source§

type Error = NumberTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for u32

Source§

type Error = NumberTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for u64

Source§

type Error = NumberTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for u128

Source§

type Error = NumberTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for Box<str>

Available on crate features alloc or std only.
Source§

type Error = StringTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for Box<[u8]>

Available on crate features alloc or std only.
Source§

type Error = BytesTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for String

Available on crate features alloc or std only.
Source§

type Error = StringTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for Arc<str>

Available on crate features alloc or std only.
Source§

type Error = StringTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for Arc<[u8]>

Available on crate features alloc or std only.
Source§

type Error = BytesTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for Vec<u8>

Available on crate features alloc or std only.
Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.

Encodes the value into the given writer.

§Note

The implementation of this method is not optimized, which means if your writer is expensive (e.g. TcpStream, File), it is better to use a BufWriter to wrap your orginal writer to cut down the number of I/O times.

Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.

Encodes the value into the given async writer.

§Note

The implementation of this method is not optimized, which means if your writer is expensive (e.g. TcpStream, File), it is better to use a BufWriter to wrap your orginal writer to cut down the number of I/O times.

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.

Decodes the value from the given reader.

§Note

The implementation of this method is not optimized, which means if your reader is expensive (e.g. TcpStream, File), it is better to use a BufReader to wrap your orginal reader to cut down the number of I/O times.

Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.

Decodes the value from the given async reader.

§Note

The implementation of this method is not optimized, which means if your reader is expensive (e.g. TcpStream, File), it is better to use a BufReader to wrap your orginal reader to cut down the number of I/O times.

Source§

type Error = BytesTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

impl Transformable for Ipv4Addr

Available on crate feature std only.
Source§

type Error = AddrTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for Ipv6Addr

Available on crate feature std only.
Source§

type Error = AddrTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for SocketAddrV4

Available on crate feature std only.
Source§

type Error = AddrTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for SocketAddrV6

Available on crate feature std only.
Source§

type Error = AddrTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for Duration

Source§

type Error = DurationTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>
where Self::Error: Send + Sync + 'static,

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized, Self::Error: Send + Sync + 'static,

Available on crate feature async only.
Source§

impl Transformable for Instant

Available on crate feature std only.
Source§

type Error = InstantTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>
where Self::Error: Send + Sync + 'static,

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized, Self::Error: Send + Sync + 'static,

Available on crate feature async only.
Source§

impl Transformable for SystemTime

Available on crate feature std only.
Source§

type Error = SystemTimeTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, writer: &mut W) -> Result<usize>

Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, writer: &mut W, ) -> Result<usize>
where Self::Error: Send + Sync + 'static,

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R, ) -> Result<(usize, Self)>
where Self: Sized, Self::Error: Send + Sync + 'static,

Available on crate feature async only.
Source§

impl Transformable for Bytes

Available on crate features alloc or std only.
Source§

type Error = BytesTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for SmolStr

Available on crate features alloc or std only.
Source§

type Error = StringTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for SmolStr

Available on crate features alloc or std only.
Source§

type Error = StringTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for Arc<str>

Available on crate features alloc or std only.
Source§

type Error = StringTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl Transformable for Arc<[u8]>

Available on crate features alloc or std only.
Source§

type Error = BytesTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.
Source§

impl<const N: usize> Transformable for SmallVec<[u8; N]>

Available on crate feature smallvec1 only.
Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.

Encodes the value into the given writer.

§Note

The implementation of this method is not optimized, which means if your writer is expensive (e.g. TcpStream, File), it is better to use a BufWriter to wrap your orginal writer to cut down the number of I/O times.

Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.

Encodes the value into the given async writer.

§Note

The implementation of this method is not optimized, which means if your writer is expensive (e.g. TcpStream, File), it is better to use a BufWriter to wrap your orginal writer to cut down the number of I/O times.

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.

Decodes the value from the given reader.

§Note

The implementation of this method is not optimized, which means if your reader is expensive (e.g. TcpStream, File), it is better to use a BufReader to wrap your orginal reader to cut down the number of I/O times.

Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.

Decodes the value from the given async reader.

§Note

The implementation of this method is not optimized, which means if your reader is expensive (e.g. TcpStream, File), it is better to use a BufReader to wrap your orginal reader to cut down the number of I/O times.

Source§

type Error = BytesTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

impl<const N: usize> Transformable for [u8; N]

Source§

type Error = BytesTransformError

Source§

fn encode(&self, dst: &mut [u8]) -> Result<usize, Self::Error>

Source§

fn encode_to_writer<W: Write>(&self, dst: &mut W) -> Result<usize>

Available on crate feature std only.
Source§

async fn encode_to_async_writer<W: AsyncWrite + Send + Unpin>( &self, dst: &mut W, ) -> Result<usize>

Available on crate feature async only.
Source§

fn encoded_len(&self) -> usize

Source§

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Source§

fn decode_from_reader<R: Read>(src: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature std only.
Source§

async fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( src: &mut R, ) -> Result<(usize, Self)>
where Self: Sized,

Available on crate feature async only.

Implementors§