Trait mesh::payload::MessageEncode
source · pub trait MessageEncode<T, R>: Sized {
// Required methods
fn write_message(item: T, writer: MessageWriter<'_, '_, R>);
fn compute_message_size(item: &mut T, sizer: MessageSizer<'_>);
}
Expand description
The MessageEncode
trait provides a message encoder for type T
.
R
is the external resource type, which allows encoding objects with
non-protobuf resources such as file descriptors. Most implementors of this
trait will be generic over all R
.
Required Methods§
sourcefn write_message(item: T, writer: MessageWriter<'_, '_, R>)
fn write_message(item: T, writer: MessageWriter<'_, '_, R>)
Writes item
as a message.
sourcefn compute_message_size(item: &mut T, sizer: MessageSizer<'_>)
fn compute_message_size(item: &mut T, sizer: MessageSizer<'_>)
Computes the size of item
as a message.
Encoding will panic if the write_message
call writes a different
number of bytes than computed by this call.
Takes a mut reference to allow mutating/stabilizing the value so that
the subsequent call to write_message
acts on the same value as this
call.
Object Safety§
This trait is not object safe.