pub trait Message: Debug + Clear + Any + Send + Sync {
Show 29 methods
fn descriptor(&self) -> &'static MessageDescriptor;
fn is_initialized(&self) -> bool;
fn merge_from(
&mut self,
is: &mut CodedInputStream<'_>
) -> Result<(), ProtobufError>;
fn write_to_with_cached_sizes(
&self,
os: &mut CodedOutputStream<'_>
) -> Result<(), ProtobufError>;
fn compute_size(&self) -> u32;
fn get_cached_size(&self) -> u32;
fn get_unknown_fields(&'s self) -> &'s UnknownFields;
fn mut_unknown_fields(&'s mut self) -> &'s mut UnknownFields;
fn as_any(&self) -> &(dyn Any + 'static);
fn new() -> Self;
fn default_instance() -> &'static Self;
fn parse_from(is: &mut CodedInputStream<'_>) -> Result<Self, ProtobufError> { ... }
fn write_to(
&self,
os: &mut CodedOutputStream<'_>
) -> Result<(), ProtobufError> { ... }
fn write_length_delimited_to(
&self,
os: &mut CodedOutputStream<'_>
) -> Result<(), ProtobufError> { ... }
fn write_length_delimited_to_vec(
&self,
vec: &mut Vec<u8, Global>
) -> Result<(), ProtobufError> { ... }
fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<(), ProtobufError> { ... }
fn parse_from_reader(reader: &mut dyn Read) -> Result<Self, ProtobufError> { ... }
fn parse_from_bytes(bytes: &[u8]) -> Result<Self, ProtobufError> { ... }
fn parse_from_carllerche_bytes(bytes: &Bytes) -> Result<Self, ProtobufError> { ... }
fn check_initialized(&self) -> Result<(), ProtobufError> { ... }
fn write_to_writer(&self, w: &mut dyn Write) -> Result<(), ProtobufError> { ... }
fn write_to_vec(&self, v: &mut Vec<u8, Global>) -> Result<(), ProtobufError> { ... }
fn write_to_bytes(&self) -> Result<Vec<u8, Global>, ProtobufError> { ... }
fn write_length_delimited_to_writer(
&self,
w: &mut dyn Write
) -> Result<(), ProtobufError> { ... }
fn write_length_delimited_to_bytes(
&self
) -> Result<Vec<u8, Global>, ProtobufError> { ... }
fn type_id(&self) -> TypeId { ... }
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static) { ... }
fn into_any(self: Box<Self, Global>) -> Box<dyn Any + 'static, Global> { ... }
fn descriptor_static() -> &'static MessageDescriptor { ... }
}
Expand description
Trait implemented for all generated structs for protobuf messages.
Also, generated messages implement Clone + Default + PartialEq
Required methods
fn descriptor(&self) -> &'static MessageDescriptor
fn descriptor(&self) -> &'static MessageDescriptor
Message descriptor for this message, used for reflection.
fn is_initialized(&self) -> bool
fn is_initialized(&self) -> bool
True iff all required fields are initialized.
Always returns true
for protobuf 3.
fn merge_from(
&mut self,
is: &mut CodedInputStream<'_>
) -> Result<(), ProtobufError>
fn merge_from(
&mut self,
is: &mut CodedInputStream<'_>
) -> Result<(), ProtobufError>
Update this message object with fields read from given stream.
fn write_to_with_cached_sizes(
&self,
os: &mut CodedOutputStream<'_>
) -> Result<(), ProtobufError>
fn write_to_with_cached_sizes(
&self,
os: &mut CodedOutputStream<'_>
) -> Result<(), ProtobufError>
Write message to the stream.
Sizes of this messages and nested messages must be cached
by calling compute_size
prior to this call.
fn compute_size(&self) -> u32
fn compute_size(&self) -> u32
Compute and cache size of this message and all nested messages
fn get_cached_size(&self) -> u32
fn get_cached_size(&self) -> u32
Get size previously computed by compute_size
.
fn get_unknown_fields(&'s self) -> &'s UnknownFields
fn get_unknown_fields(&'s self) -> &'s UnknownFields
Get a reference to unknown fields.
fn mut_unknown_fields(&'s mut self) -> &'s mut UnknownFields
fn mut_unknown_fields(&'s mut self) -> &'s mut UnknownFields
Get a mutable reference to unknown fields.
fn default_instance() -> &'static Self
fn default_instance() -> &'static Self
Return a pointer to default immutable message with static lifetime.
let m: &MyMessage = MyMessage::default_instance();
Provided methods
fn parse_from(is: &mut CodedInputStream<'_>) -> Result<Self, ProtobufError>
fn parse_from(is: &mut CodedInputStream<'_>) -> Result<Self, ProtobufError>
Parse message from stream.
fn write_to(&self, os: &mut CodedOutputStream<'_>) -> Result<(), ProtobufError>
fn write_to(&self, os: &mut CodedOutputStream<'_>) -> Result<(), ProtobufError>
Write the message to the stream.
Results in error if message is not fully initialized.
fn write_length_delimited_to(
&self,
os: &mut CodedOutputStream<'_>
) -> Result<(), ProtobufError>
fn write_length_delimited_to(
&self,
os: &mut CodedOutputStream<'_>
) -> Result<(), ProtobufError>
Write the message to the stream prepending the message with message length encoded as varint.
fn write_length_delimited_to_vec(
&self,
vec: &mut Vec<u8, Global>
) -> Result<(), ProtobufError>
fn write_length_delimited_to_vec(
&self,
vec: &mut Vec<u8, Global>
) -> Result<(), ProtobufError>
Write the message to the vec, prepend the message with message length encoded as varint.
fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<(), ProtobufError>
fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<(), ProtobufError>
Update this message object with fields read from given stream.
fn parse_from_reader(reader: &mut dyn Read) -> Result<Self, ProtobufError>
fn parse_from_reader(reader: &mut dyn Read) -> Result<Self, ProtobufError>
Parse message from reader. Parse stops on EOF or when error encountered.
fn parse_from_bytes(bytes: &[u8]) -> Result<Self, ProtobufError>
fn parse_from_bytes(bytes: &[u8]) -> Result<Self, ProtobufError>
Parse message from byte array.
fn parse_from_carllerche_bytes(bytes: &Bytes) -> Result<Self, ProtobufError>
fn parse_from_carllerche_bytes(bytes: &Bytes) -> Result<Self, ProtobufError>
Parse message from Bytes
object.
Resulting message may share references to the passed bytes object.
fn check_initialized(&self) -> Result<(), ProtobufError>
fn check_initialized(&self) -> Result<(), ProtobufError>
Check if all required fields of this object are initialized.
fn write_to_writer(&self, w: &mut dyn Write) -> Result<(), ProtobufError>
fn write_to_writer(&self, w: &mut dyn Write) -> Result<(), ProtobufError>
Write the message to the writer.
fn write_to_vec(&self, v: &mut Vec<u8, Global>) -> Result<(), ProtobufError>
fn write_to_vec(&self, v: &mut Vec<u8, Global>) -> Result<(), ProtobufError>
Write the message to bytes vec.
fn write_to_bytes(&self) -> Result<Vec<u8, Global>, ProtobufError>
fn write_to_bytes(&self) -> Result<Vec<u8, Global>, ProtobufError>
Write the message to bytes vec.
fn write_length_delimited_to_writer(
&self,
w: &mut dyn Write
) -> Result<(), ProtobufError>
fn write_length_delimited_to_writer(
&self,
w: &mut dyn Write
) -> Result<(), ProtobufError>
Write the message to the writer, prepend the message with message length encoded as varint.
fn write_length_delimited_to_bytes(
&self
) -> Result<Vec<u8, Global>, ProtobufError>
fn write_length_delimited_to_bytes(
&self
) -> Result<Vec<u8, Global>, ProtobufError>
Write the message to the bytes vec, prepend the message with message length encoded as varint.
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
View self as mutable Any
.
Convert boxed self to boxed Any
.
fn descriptor_static() -> &'static MessageDescriptor
fn descriptor_static() -> &'static MessageDescriptor
Get message descriptor for message type.
let descriptor = MyMessage::descriptor_static();
assert_eq!("MyMessage", descriptor.name());