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>

source

pub fn new(message: &'a dyn MessageDyn) -> MessageRef<'a>

Wrap a message.

source

pub fn default_instance(message: &MessageDescriptor) -> MessageRef<'static>

Default (empty) instance of given message type.

Methods from Deref<Target = 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 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 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 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<'a> Clone for MessageRef<'a>

source§

fn clone(&self) -> MessageRef<'a>

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> Debug for MessageRef<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Deref for MessageRef<'a>

§

type Target = dyn MessageDyn

The resulting type after dereferencing.
source§

fn deref(&self) -> &dyn MessageDyn

Dereferences the value.
source§

impl<'a> Display for MessageRef<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, M: MessageFull> From<&'a M> for MessageRef<'a>

source§

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

Converts to this type from the input type.
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<'a> ReflectEq for MessageRef<'a>

source§

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.