ConvertWireFormat

Trait ConvertWireFormat 

Source
pub trait ConvertWireFormat: WireFormat {
    // Required methods
    fn to_bytes(&self) -> Bytes;
    fn from_bytes(buf: &Bytes) -> Result<Self, Error>
       where Self: Sized;

    // Provided method
    fn as_bytes(&self) -> Vec<u8>  { ... }
}
Expand description

A trait for converting types to and from a wire format.

Required Methods§

Source

fn to_bytes(&self) -> Bytes

Converts the type to a byte representation.

§Returns

A Bytes object representing the byte representation of the type.

Source

fn from_bytes(buf: &Bytes) -> Result<Self, Error>
where Self: Sized,

Converts a byte buffer to the type.

§Arguments
  • buf - A mutable reference to a Bytes object containing the byte buffer.
§Returns

A Result containing the converted type or an std::io::Error if the conversion fails.

Provided Methods§

Source

fn as_bytes(&self) -> Vec<u8>

AsRef<u8> for the type.

§Returns

A reference to the byte representation of the type.

Implementors§

Source§

impl<T> ConvertWireFormat for T
where T: WireFormat,

Implements the ConvertWireFormat trait for types that implement jetstream_p9::WireFormat. This trait provides methods for converting the type to and from bytes.