Struct protobuf::reflect::MessageRef
source · [−]pub struct MessageRef<'a> { /* private fields */ }
Expand description
Wrapper around either MessageFull
reference or a container for an empty dynamic message.
Implementations
sourceimpl<'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
sourceimpl<'a> Clone for MessageRef<'a>
impl<'a> Clone for MessageRef<'a>
sourcefn clone(&self) -> MessageRef<'a>
fn clone(&self) -> MessageRef<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a> Debug for MessageRef<'a>
impl<'a> Debug for MessageRef<'a>
sourceimpl<'a> Deref for MessageRef<'a>
impl<'a> Deref for MessageRef<'a>
type Target = dyn MessageDyn + 'static
type Target = dyn MessageDyn + 'static
The resulting type after dereferencing.
sourcefn deref(&self) -> &dyn MessageDyn
fn deref(&self) -> &dyn MessageDyn
Dereferences the value.
sourceimpl<'a> Display for MessageRef<'a>
impl<'a> Display for MessageRef<'a>
sourceimpl<'a> From<&'a (dyn MessageDyn + 'static)> for MessageRef<'a>
impl<'a> From<&'a (dyn MessageDyn + 'static)> for MessageRef<'a>
sourcefn from(m: &'a dyn MessageDyn) -> Self
fn from(m: &'a dyn MessageDyn) -> Self
Converts to this type from the input type.
sourceimpl<'a, M: MessageFull> From<&'a M> for MessageRef<'a>
impl<'a, M: MessageFull> From<&'a M> for MessageRef<'a>
sourceimpl<'a> ReflectEq for MessageRef<'a>
impl<'a> ReflectEq for MessageRef<'a>
sourcefn reflect_eq(&self, that: &Self, mode: &ReflectEqMode) -> bool
fn reflect_eq(&self, that: &Self, mode: &ReflectEqMode) -> bool
Perform the equality comparison.
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more