jetstream_wireformat::wire_format_extensions

Trait ConvertWireFormat

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> ⓘ { ... }
}

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

Required Methods

fn to_bytes(&self) -> Bytes

Converts the type to a byte representation.

Returns

A Bytes object representing the byte representation of the type.

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

fn as_bytes(&self) -> Vec

AsRef< u8> for the type.

Returns

A reference to the byte representation of the type.

Implementors

impl ConvertWireFormat for Twhere 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.