Skip to main content

MessageDyn

Trait 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 duplicate of the value. Read more
1.0.0 (const: unstable) · 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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§