Trait protobuf::MessageDyn

source ·
pub trait MessageDyn: Any + Debug + Display + Send + Sync + 'static {
    // Required methods
    fn descriptor_dyn(&self) -> MessageDescriptor;
    fn merge_from_dyn(&mut self, is: &mut CodedInputStream<'_>) -> Result<()>;
    fn write_to_with_cached_sizes_dyn(
        &self,
        os: &mut CodedOutputStream<'_>
    ) -> Result<()>;
    fn compute_size_dyn(&self) -> u64;
    fn is_initialized_dyn(&self) -> bool;
    fn special_fields_dyn(&self) -> &SpecialFields;
    fn mut_special_fields_dyn(&mut self) -> &mut SpecialFields;
}
Expand description

Dynamic-dispatch version of either generated message or dynamic message.

Generated messages implement MessageFull unless lite runtime requested. Dynamic messages can be created with FileDescriptor::new_dynamic.

Required Methods§

source

fn descriptor_dyn(&self) -> MessageDescriptor

Message descriptor for this message, used for reflection.

source

fn merge_from_dyn(&mut self, is: &mut CodedInputStream<'_>) -> Result<()>

Update this message fields with contents of given stream.

source

fn write_to_with_cached_sizes_dyn( &self, os: &mut CodedOutputStream<'_> ) -> Result<()>

Write the message.

source

fn compute_size_dyn(&self) -> u64

Compute (and cache) the message size.

source

fn is_initialized_dyn(&self) -> bool

True iff all required fields are initialized. Always returns true for protobuf 3.

source

fn special_fields_dyn(&self) -> &SpecialFields

Get a reference to special fields.

source

fn mut_special_fields_dyn(&mut self) -> &mut SpecialFields

Get a mutable reference to special fields.

Implementations§

source§

impl dyn MessageDyn

source

pub fn check_initialized_dyn(&self) -> Result<()>

Check if all required fields of this object are initialized.

source

pub fn write_to_writer_dyn(&self, w: &mut dyn Write) -> Result<()>

Write the message to the writer.

source

pub fn write_to_vec_dyn(&self, v: &mut Vec<u8>) -> Result<()>

Write the message to bytes vec.

source

pub fn write_to_dyn(&self, os: &mut CodedOutputStream<'_>) -> Result<()>

Write the message to the stream.

Results in error if message is not fully initialized.

source

pub fn write_length_delimited_to_vec_dyn(&self, vec: &mut Vec<u8>) -> Result<()>

Write the message to the vec, prepend the message with message length encoded as varint.

source

pub fn merge_from_bytes_dyn(&mut self, bytes: &[u8]) -> Result<()>

Update this message object with fields read from given stream.

source

pub fn write_to_bytes_dyn(&self) -> Result<Vec<u8>>

Write the message to bytes vec.

Note: You can use Message::parse_from_bytes to do the reverse.

source

pub fn write_length_delimited_to_dyn( &self, os: &mut CodedOutputStream<'_> ) -> Result<()>

Write the message to the stream prepending the message with message length encoded as varint.

source

pub fn write_length_delimited_to_writer_dyn( &self, w: &mut dyn Write ) -> Result<()>

Write the message to the writer, prepend the message with message length encoded as varint.

source

pub fn write_length_delimited_to_bytes_dyn(&self) -> Result<Vec<u8>>

Write the message to the bytes vec, prepend the message with message length encoded as varint.

source

pub fn unknown_fields_dyn(&self) -> &UnknownFields

Get a reference to unknown fields.

source

pub fn mut_unknown_fields_dyn(&mut self) -> &mut UnknownFields

Get a mutable reference to unknown fields.

source

pub fn downcast_box<T: Any>( self: Box<dyn MessageDyn> ) -> Result<Box<T>, Box<dyn MessageDyn>>

Downcast Box<dyn Message> to specific message type.

let m: Box<dyn MessageDyn> = message;
let m: Box<MyMessage> = <dyn MessageDyn>::downcast_box(m).unwrap();
source

pub fn downcast_ref<'a, M: MessageFull + 'a>(&'a self) -> Option<&'a M>

Downcast &dyn Message to specific message type.

let m: &dyn MessageDyn = message;
let m: &MyMessage = <dyn MessageDyn>::downcast_ref(m).unwrap();
source

pub fn downcast_mut<'a, M: MessageFull + 'a>(&'a mut self) -> Option<&'a mut M>

Downcast &mut dyn Message to specific message type.

let m: &mut dyn MessageDyn = message;
let m: &mut MyMessage = <dyn MessageDyn>::downcast_mut(m).unwrap();
source

pub fn clone_box(&self) -> Box<dyn MessageDyn>

Clone from a dyn Message reference.

source

pub fn reflect_eq_dyn( &self, other: &dyn MessageDyn, mode: &ReflectEqMode ) -> bool

Reflectively compare the messages.

Trait Implementations§

source§

impl Clone for Box<dyn MessageDyn>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> From<&'a (dyn MessageDyn + 'static)> for MessageRef<'a>

source§

fn from(m: &'a dyn MessageDyn) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Box<dyn MessageDyn>

source§

fn eq(&self, other: &Box<dyn MessageDyn>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Implementors§