Trait protobuf::MessageDyn [−][src]
pub trait MessageDyn: Any + Debug + Send + Sync + 'static {
fn descriptor_dyn(&self) -> MessageDescriptor;
fn merge_from_dyn(
&mut self,
is: &mut CodedInputStream<'_>
) -> ProtobufResult<()>;
fn write_to_with_cached_sizes_dyn(
&self,
os: &mut CodedOutputStream<'_>
) -> ProtobufResult<()>;
fn compute_size_dyn(&self) -> u32;
fn is_initialized_dyn(&self) -> bool;
fn get_unknown_fields_dyn(&self) -> &UnknownFields;
fn mut_unknown_fields_dyn(&mut self) -> &mut UnknownFields;
}
Expand description
Dynamic-dispatch version of Message
.
Required methods
fn descriptor_dyn(&self) -> MessageDescriptor
fn descriptor_dyn(&self) -> MessageDescriptor
Message descriptor for this message, used for reflection.
fn merge_from_dyn(
&mut self,
is: &mut CodedInputStream<'_>
) -> ProtobufResult<()>
fn merge_from_dyn(
&mut self,
is: &mut CodedInputStream<'_>
) -> ProtobufResult<()>
Update this message fields with contents of given stream.
fn write_to_with_cached_sizes_dyn(
&self,
os: &mut CodedOutputStream<'_>
) -> ProtobufResult<()>
fn write_to_with_cached_sizes_dyn(
&self,
os: &mut CodedOutputStream<'_>
) -> ProtobufResult<()>
Write the message.
fn compute_size_dyn(&self) -> u32
fn compute_size_dyn(&self) -> u32
Compute (and cache) the message size.
fn is_initialized_dyn(&self) -> bool
fn is_initialized_dyn(&self) -> bool
True iff all required fields are initialized.
Always returns true
for protobuf 3.
fn get_unknown_fields_dyn(&self) -> &UnknownFields
fn get_unknown_fields_dyn(&self) -> &UnknownFields
Get a reference to unknown fields.
fn mut_unknown_fields_dyn(&mut self) -> &mut UnknownFields
fn mut_unknown_fields_dyn(&mut self) -> &mut UnknownFields
Get a mutable reference to unknown fields.
Implementations
Check if all required fields of this object are initialized.
Write the message to the writer.
Write the message to bytes vec.
Write the message to the stream.
Results in error if message is not fully initialized.
Write the message to the vec, prepend the message with message length encoded as varint.
Update this message object with fields read from given stream.
Write the message to bytes vec.
Note: You can use
Message::parse_from_bytes
to do the reverse.
pub fn write_length_delimited_to_dyn(
&self,
os: &mut CodedOutputStream<'_>
) -> ProtobufResult<()>
pub fn write_length_delimited_to_dyn(
&self,
os: &mut CodedOutputStream<'_>
) -> ProtobufResult<()>
Write the message to the stream prepending the message with message length encoded as varint.
Write the message to the writer, prepend the message with message length encoded as varint.
Write the message to the bytes vec, prepend the message with message length encoded as varint.
Downcast Box<dyn Message>
to specific message type.
let m: Box<dyn MessageDyn> = message;
let m: Box<MyMessage> = MessageDyn::downcast_box(m).unwrap();
Downcast &dyn Message
to specific message type.
let m: &dyn MessageDyn = message;
let m: &MyMessage = MessageDyn::downcast_ref(m).unwrap();
Downcast &mut dyn Message
to specific message type.
let m: &mut dyn MessageDyn = message;
let m: &mut MyMessage = MessageDyn::downcast_mut(m).unwrap();
Clone from a dyn Message
reference.
Reflectively compare the messages.
Trait Implementations
Performs the conversion.