Skip to main content

DynamicMessage

Struct DynamicMessage 

Source
pub struct DynamicMessage<'pool, 'msg> { /* private fields */ }
Expand description

Mutable view of a protobuf message for dynamic modification.

Extends DynamicMessageRef with mutation capabilities. Use for decoding messages or setting field values dynamically.

Implements Deref<Target = DynamicMessageRef> so all read methods are available.

Implementations§

Source§

impl<'pool, 'msg> DynamicMessage<'pool, 'msg>

Source

pub fn as_ref<'a>(&'a self) -> DynamicMessageRef<'pool, 'a>

Source

pub fn clear(&mut self)

Zeroes all fields of this message.

Methods from Deref<Target = DynamicMessageRef<'pool, 'msg>>§

Source

pub fn descriptor(&self) -> &'pool DescriptorProto

Source

pub fn find_field_descriptor( &self, field_name: &str, ) -> Option<&'pool FieldDescriptorProto>

Source

pub fn find_field_descriptor_by_number( &self, field_number: i32, ) -> Option<&'pool FieldDescriptorProto>

Source

pub fn get_field( &self, field: &'pool FieldDescriptorProto, ) -> Option<Value<'pool, 'msg>>

Trait Implementations§

Source§

impl<'pool, 'msg> Debug for DynamicMessage<'pool, 'msg>

Source§

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

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

impl<'pool, 'msg> Deref for DynamicMessage<'pool, 'msg>

Source§

type Target = DynamicMessageRef<'pool, 'msg>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'pool, 'msg> From<DynamicMessage<'pool, 'msg>> for DynamicMessageRef<'pool, 'msg>

Source§

fn from(dynamic: DynamicMessage<'pool, 'msg>) -> Self

Converts to this type from the input type.
Source§

impl<'pool, 'msg> ProtobufMut<'pool> for DynamicMessage<'pool, 'msg>

Source§

fn as_dyn_mut<'a>(&'a mut self) -> DynamicMessage<'pool, 'a>

Get a mutable dynamic view of this message.
Source§

fn decode_flat<const STACK_DEPTH: usize>( &mut self, arena: &mut Arena<'_>, buf: &[u8], ) -> bool

Decode from a byte slice. Returns true on success.
Source§

fn decode<'a, E>( &mut self, arena: &mut Arena<'_>, provider: &'a mut impl FnMut() -> Result<Option<&'a [u8]>, E>, ) -> Result<(), Error<E>>

Source§

fn async_decode<'a, E, F>( &'a mut self, arena: &mut Arena<'_>, provider: &'a mut impl FnMut() -> F, ) -> impl Future<Output = Result<(), Error<E>>>
where F: Future<Output = Result<Option<&'a [u8]>, E>> + 'a,

Source§

fn decode_from_bufread<const STACK_DEPTH: usize>( &mut self, arena: &mut Arena<'_>, reader: &mut impl BufRead, ) -> Result<(), Error<Error>>

Source§

fn decode_from_read<const STACK_DEPTH: usize>( &mut self, arena: &mut Arena<'_>, reader: &mut impl Read, ) -> Result<(), Error<Error>>

Source§

fn decode_from_async_bufread<'a, const STACK_DEPTH: usize>( &'a mut self, arena: &'a mut Arena<'a>, reader: &mut (impl AsyncBufRead + Unpin), ) -> impl Future<Output = Result<(), Error<Error>>>

Source§

fn decode_from_async_read<'a, const STACK_DEPTH: usize>( &'a mut self, arena: &'a mut Arena<'a>, reader: &mut (impl AsyncRead + Unpin), ) -> impl Future<Output = Result<(), Error<Error>>>

Source§

fn serde_deserialize<'arena, 'alloc, 'de, D>( &'de mut self, arena: &'arena mut Arena<'alloc>, deserializer: D, ) -> Result<(), D::Error>
where D: Deserializer<'de>,

Source§

impl<'pool, 'msg> ProtobufRef<'pool> for DynamicMessage<'pool, 'msg>

Source§

fn as_dyn<'a>(&'a self) -> DynamicMessageRef<'pool, 'a>

Get a dynamic view of this message for reflection.
Source§

fn descriptor(&self) -> &'pool ProtoType

Get the message’s descriptor (schema metadata).
Source§

fn encode_flat<'a, const STACK_DEPTH: usize>( &self, buffer: &'a mut [u8], ) -> Result<&'a [u8], Error>

Encode to a fixed buffer. Returns the encoded slice or an error.
Source§

fn encode_vec<const STACK_DEPTH: usize>(&self) -> Result<Vec<u8>, Error>

Encode to a new Vec, growing as needed.

Auto Trait Implementations§

§

impl<'pool, 'msg> !UnwindSafe for DynamicMessage<'pool, 'msg>

§

impl<'pool, 'msg> Freeze for DynamicMessage<'pool, 'msg>

§

impl<'pool, 'msg> RefUnwindSafe for DynamicMessage<'pool, 'msg>

§

impl<'pool, 'msg> Send for DynamicMessage<'pool, 'msg>

§

impl<'pool, 'msg> Sync for DynamicMessage<'pool, 'msg>

§

impl<'pool, 'msg> Unpin for DynamicMessage<'pool, 'msg>

§

impl<'pool, 'msg> UnsafeUnpin for DynamicMessage<'pool, 'msg>

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.