pub struct MessageRef<'a> { /* private fields */ }
Expand description
Wrapper around either MessageFull
reference or a container for an empty dynamic message.
Implementations§
Source§impl<'a> MessageRef<'a>
impl<'a> MessageRef<'a>
Sourcepub fn new(message: &'a dyn MessageDyn) -> MessageRef<'a>
pub fn new(message: &'a dyn MessageDyn) -> MessageRef<'a>
Wrap a message.
Sourcepub fn default_instance(message: &MessageDescriptor) -> MessageRef<'static>
pub fn default_instance(message: &MessageDescriptor) -> MessageRef<'static>
Default (empty) instance of given message type.
Methods from Deref<Target = dyn MessageDyn>§
Sourcepub fn check_initialized_dyn(&self) -> Result<()>
pub fn check_initialized_dyn(&self) -> Result<()>
Check if all required fields of this object are initialized.
Sourcepub fn write_to_writer_dyn(&self, w: &mut dyn Write) -> Result<()>
pub fn write_to_writer_dyn(&self, w: &mut dyn Write) -> Result<()>
Write the message to the writer.
Sourcepub fn write_to_dyn(&self, os: &mut CodedOutputStream<'_>) -> Result<()>
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.
Sourcepub fn write_length_delimited_to_vec_dyn(&self, vec: &mut Vec<u8>) -> Result<()>
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.
Sourcepub fn write_to_bytes_dyn(&self) -> Result<Vec<u8>>
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.
Sourcepub fn write_length_delimited_to_dyn(
&self,
os: &mut CodedOutputStream<'_>,
) -> Result<()>
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.
Sourcepub fn write_length_delimited_to_writer_dyn(
&self,
w: &mut dyn Write,
) -> Result<()>
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.
Sourcepub fn write_length_delimited_to_bytes_dyn(&self) -> Result<Vec<u8>>
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.
Sourcepub fn unknown_fields_dyn(&self) -> &UnknownFields
pub fn unknown_fields_dyn(&self) -> &UnknownFields
Get a reference to unknown fields.
Sourcepub fn downcast_ref<'a, M: MessageFull + 'a>(&'a self) -> Option<&'a M>
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();
Sourcepub fn clone_box(&self) -> Box<dyn MessageDyn>
pub fn clone_box(&self) -> Box<dyn MessageDyn>
Clone from a dyn Message
reference.
Sourcepub fn reflect_eq_dyn(
&self,
other: &dyn MessageDyn,
mode: &ReflectEqMode,
) -> bool
pub fn reflect_eq_dyn( &self, other: &dyn MessageDyn, mode: &ReflectEqMode, ) -> bool
Reflectively compare the messages.
Trait Implementations§
Source§impl<'a> Clone for MessageRef<'a>
impl<'a> Clone for MessageRef<'a>
Source§fn clone(&self) -> MessageRef<'a>
fn clone(&self) -> MessageRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more