protobuf::reflect

Struct MessageRef

Source
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>

Source§

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> !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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

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>,

Source§

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>,

Source§

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.