pub trait MessageDyn:
Any
+ Debug
+ Display
+ Send
+ Sync
+ 'static {
// Required methods
fn descriptor_dyn(&self) -> MessageDescriptor;
fn merge_from_dyn(&mut self, is: &mut CodedInputStream<'_>) -> Result<()>;
fn write_to_with_cached_sizes_dyn(
&self,
os: &mut CodedOutputStream<'_>,
) -> Result<()>;
fn compute_size_dyn(&self) -> u64;
fn is_initialized_dyn(&self) -> bool;
fn special_fields_dyn(&self) -> &SpecialFields;
fn mut_special_fields_dyn(&mut self) -> &mut SpecialFields;
}
Expand description
Dynamic-dispatch version of either generated message or dynamic message.
Generated messages implement MessageFull
unless lite runtime requested.
Dynamic messages can be created with
FileDescriptor::new_dynamic
.
Required Methods§
Sourcefn descriptor_dyn(&self) -> MessageDescriptor
fn descriptor_dyn(&self) -> MessageDescriptor
Message descriptor for this message, used for reflection.
Sourcefn merge_from_dyn(&mut self, is: &mut CodedInputStream<'_>) -> Result<()>
fn merge_from_dyn(&mut self, is: &mut CodedInputStream<'_>) -> Result<()>
Update this message fields with contents of given stream.
Sourcefn write_to_with_cached_sizes_dyn(
&self,
os: &mut CodedOutputStream<'_>,
) -> Result<()>
fn write_to_with_cached_sizes_dyn( &self, os: &mut CodedOutputStream<'_>, ) -> Result<()>
Write the message.
Sourcefn compute_size_dyn(&self) -> u64
fn compute_size_dyn(&self) -> u64
Compute (and cache) the message size.
Sourcefn is_initialized_dyn(&self) -> bool
fn is_initialized_dyn(&self) -> bool
True iff all required fields are initialized.
Always returns true
for protobuf 3.
Sourcefn special_fields_dyn(&self) -> &SpecialFields
fn special_fields_dyn(&self) -> &SpecialFields
Get a reference to special fields.
Sourcefn mut_special_fields_dyn(&mut self) -> &mut SpecialFields
fn mut_special_fields_dyn(&mut self) -> &mut SpecialFields
Get a mutable reference to special fields.
Implementations§
Source§impl dyn MessageDyn
impl 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 merge_from_bytes_dyn(&mut self, bytes: &[u8]) -> Result<()>
pub fn merge_from_bytes_dyn(&mut self, bytes: &[u8]) -> Result<()>
Update this message object with fields read from given stream.
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 mut_unknown_fields_dyn(&mut self) -> &mut UnknownFields
pub fn mut_unknown_fields_dyn(&mut self) -> &mut UnknownFields
Get a mutable reference to unknown fields.
Sourcepub fn downcast_box<T: Any>(
self: Box<dyn MessageDyn>,
) -> Result<Box<T>, Box<dyn MessageDyn>>
pub fn downcast_box<T: Any>( self: Box<dyn MessageDyn>, ) -> Result<Box<T>, Box<dyn MessageDyn>>
Downcast Box<dyn Message>
to specific message type.
let m: Box<dyn MessageDyn> = message;
let m: Box<MyMessage> = <dyn MessageDyn>::downcast_box(m).unwrap();
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 downcast_mut<'a, M: MessageFull + 'a>(&'a mut self) -> Option<&'a mut M>
pub fn downcast_mut<'a, M: MessageFull + 'a>(&'a mut self) -> Option<&'a mut M>
Downcast &mut dyn Message
to specific message type.
let m: &mut dyn MessageDyn = message;
let m: &mut MyMessage = <dyn MessageDyn>::downcast_mut(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.