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 moresource§impl<'a> Debug for MessageRef<'a>
impl<'a> Debug for MessageRef<'a>
source§impl<'a> Deref for MessageRef<'a>
impl<'a> Deref for MessageRef<'a>
source§type Target = dyn MessageDyn
type Target = dyn MessageDyn
source§fn deref(&self) -> &dyn MessageDyn
fn deref(&self) -> &dyn MessageDyn
source§impl<'a> Display for MessageRef<'a>
impl<'a> Display for MessageRef<'a>
source§impl<'a, M: MessageFull> From<&'a M> for MessageRef<'a>
impl<'a, M: MessageFull> From<&'a M> for MessageRef<'a>
source§impl<'a> From<&'a (dyn MessageDyn + 'static)> for MessageRef<'a>
impl<'a> From<&'a (dyn MessageDyn + 'static)> for MessageRef<'a>
source§fn from(m: &'a dyn MessageDyn) -> Self
fn from(m: &'a dyn MessageDyn) -> Self
source§impl<'a> ReflectEq for MessageRef<'a>
impl<'a> ReflectEq for MessageRef<'a>
source§fn reflect_eq(&self, that: &Self, mode: &ReflectEqMode) -> bool
fn reflect_eq(&self, that: &Self, mode: &ReflectEqMode) -> bool
Auto Trait Implementations§
impl<'a> !Freeze for MessageRef<'a>
impl<'a> !RefUnwindSafe for MessageRef<'a>
impl<'a> Send for MessageRef<'a>
impl<'a> Sync for MessageRef<'a>
impl<'a> Unpin for MessageRef<'a>
impl<'a> !UnwindSafe for MessageRef<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)