Trait bilrost::Message

source ·
pub trait Message: EmptyState {
Show 22 methods // Required methods fn encode<B: BufMut + ?Sized>(&self, buf: &mut B) -> Result<(), EncodeError> where Self: Sized; fn prepend<B: ReverseBuf + ?Sized>(&self, buf: &mut B) where Self: Sized; fn encode_length_delimited<B: BufMut + ?Sized>( &self, buf: &mut B, ) -> Result<(), EncodeError> where Self: Sized; fn decode<B: Buf>(buf: B) -> Result<Self, DecodeError> where Self: Sized; fn decode_length_delimited<B: Buf>(buf: B) -> Result<Self, DecodeError> where Self: Sized; fn replace_from<B: Buf>(&mut self, buf: B) -> Result<(), DecodeError> where Self: Sized; fn replace_from_length_delimited<B: Buf>( &mut self, buf: B, ) -> Result<(), DecodeError> where Self: Sized; fn encoded_len(&self) -> usize; fn encode_to_vec(&self) -> Vec<u8> ; fn encode_to_bytes(&self) -> Bytes; fn encode_fast(&self) -> ReverseBuffer; fn encode_length_delimited_fast(&self) -> ReverseBuffer; fn encode_contiguous(&self) -> ReverseBuffer; fn encode_length_delimited_contiguous(&self) -> ReverseBuffer; fn encode_dyn(&self, buf: &mut dyn BufMut) -> Result<(), EncodeError>; fn encode_length_delimited_to_vec(&self) -> Vec<u8> ; fn encode_length_delimited_to_bytes(&self) -> Bytes; fn encode_length_delimited_dyn( &self, buf: &mut dyn BufMut, ) -> Result<(), EncodeError>; fn replace_from_slice(&mut self, buf: &[u8]) -> Result<(), DecodeError>; fn replace_from_length_delimited_slice( &mut self, buf: &[u8], ) -> Result<(), DecodeError>; fn replace_from_dyn(&mut self, buf: &mut dyn Buf) -> Result<(), DecodeError>; fn replace_from_length_delimited_dyn( &mut self, buf: &mut dyn Buf, ) -> Result<(), DecodeError>;
}
Expand description

A Bilrost message. Provides basic encoding and decoding functionality for message types.

Required Methods§

source

fn encode<B: BufMut + ?Sized>(&self, buf: &mut B) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer.

An error will be returned if the buffer does not have sufficient capacity.

source

fn prepend<B: ReverseBuf + ?Sized>(&self, buf: &mut B)
where Self: Sized,

Prepends the message to a buffer.

source

fn encode_length_delimited<B: BufMut + ?Sized>( &self, buf: &mut B, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer.

An error will be returned if the buffer does not have sufficient capacity.

source

fn decode<B: Buf>(buf: B) -> Result<Self, DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer.

The entire buffer will be consumed.

source

fn decode_length_delimited<B: Buf>(buf: B) -> Result<Self, DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from the buffer.

source

fn replace_from<B: Buf>(&mut self, buf: B) -> Result<(), DecodeError>
where Self: Sized,

Decodes the non-ignored fields of this message from the buffer, replacing their values.

source

fn replace_from_length_delimited<B: Buf>( &mut self, buf: B, ) -> Result<(), DecodeError>
where Self: Sized,

Decodes the non-ignored fields of this message, replacing their values from a length-delimited value encoded in the buffer.

source

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.

source

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

Encodes the message to a newly allocated buffer.

source

fn encode_to_bytes(&self) -> Bytes

Encodes the message to a Bytes buffer.

source

fn encode_fast(&self) -> ReverseBuffer

Encodes the message to a ReverseBuffer.

source

fn encode_length_delimited_fast(&self) -> ReverseBuffer

Encodes the message with a length-delimiter to a ReverseBuffer.

source

fn encode_contiguous(&self) -> ReverseBuffer

Encodes the message to a new RevserseBuffer which will have exactly the required capacity in one contiguous slice.

source

fn encode_length_delimited_contiguous(&self) -> ReverseBuffer

Encodes the message with a length-delimiter to a new RevserseBuffer which will have exactly the required capacity in one contiguous slice.

source

fn encode_dyn(&self, buf: &mut dyn BufMut) -> Result<(), EncodeError>

Encodes the message to a Bytes buffer.

source

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

Encodes the message with a length-delimiter to a newly allocated buffer.

source

fn encode_length_delimited_to_bytes(&self) -> Bytes

Encodes the message with a length-delimiter to a Bytes buffer.

source

fn encode_length_delimited_dyn( &self, buf: &mut dyn BufMut, ) -> Result<(), EncodeError>

Encodes the message with a length-delimiter to a Bytes buffer.

source

fn replace_from_slice(&mut self, buf: &[u8]) -> Result<(), DecodeError>

Decodes the non-ignored fields of this message from the buffer, replacing their values.

source

fn replace_from_length_delimited_slice( &mut self, buf: &[u8], ) -> Result<(), DecodeError>

Decodes the non-ignored fields of this message, replacing their values from a length-delimited value encoded in the buffer.

source

fn replace_from_dyn(&mut self, buf: &mut dyn Buf) -> Result<(), DecodeError>

Decodes the non-ignored fields of this message from the buffer, replacing their values.

source

fn replace_from_length_delimited_dyn( &mut self, buf: &mut dyn Buf, ) -> Result<(), DecodeError>

Decodes the non-ignored fields of this message, replacing their values from a length-delimited value encoded in the buffer.

Implementors§

source§

impl<T> Message for T
where T: RawMessage + Sized,

Message is implemented as a usability layer on top of the basic functionality afforded by RawMessage.