Trait protobuf::Message [−][src]
pub trait Message: Debug + Clear + Any + Send + Sync { fn descriptor(&self) -> &'static MessageDescriptor; fn is_initialized(&self) -> bool; fn merge_from(&mut self, is: &mut CodedInputStream) -> ProtobufResult<()>; fn write_to_with_cached_sizes(
&self,
os: &mut CodedOutputStream
) -> ProtobufResult<()>; fn compute_size(&self) -> u32; fn get_cached_size(&self) -> u32; fn get_unknown_fields<'s>(&'s self) -> &'s UnknownFields; fn mut_unknown_fields<'s>(&'s mut self) -> &'s mut UnknownFields; fn as_any(&self) -> &Any; fn new() -> Self
where
Self: Sized; fn default_instance() -> &'static Self
where
Self: Sized; fn write_to(&self, os: &mut CodedOutputStream) -> ProtobufResult<()> { ... } fn write_length_delimited_to(
&self,
os: &mut CodedOutputStream
) -> ProtobufResult<()> { ... } fn write_length_delimited_to_vec(
&self,
vec: &mut Vec<u8>
) -> ProtobufResult<()> { ... } fn merge_from_bytes(&mut self, bytes: &[u8]) -> ProtobufResult<()> { ... } fn check_initialized(&self) -> ProtobufResult<()> { ... } fn write_to_writer(&self, w: &mut Write) -> ProtobufResult<()> { ... } fn write_to_vec(&self, v: &mut Vec<u8>) -> ProtobufResult<()> { ... } fn write_to_bytes(&self) -> ProtobufResult<Vec<u8>> { ... } fn write_length_delimited_to_writer(
&self,
w: &mut Write
) -> ProtobufResult<()> { ... } fn write_length_delimited_to_bytes(&self) -> ProtobufResult<Vec<u8>> { ... } fn type_id(&self) -> TypeId { ... } fn as_any_mut(&mut self) -> &mut Any { ... } fn into_any(self: Box<Self>) -> Box<Any> { ... } fn descriptor_static() -> &'static MessageDescriptor
where
Self: Sized, { ... } }
Trait implemented for all generated structs for protobuf messages.
Also, generated messages implement Clone + Default + PartialEq
Required Methods
fn descriptor(&self) -> &'static MessageDescriptor
Message descriptor for this message, used for reflection.
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) -> ProtobufResult<()>
Update this message object with fields read from given stream.
fn write_to_with_cached_sizes(
&self,
os: &mut CodedOutputStream
) -> ProtobufResult<()>
&self,
os: &mut CodedOutputStream
) -> ProtobufResult<()>
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
Compute and cache size of this message and all nested messages
fn get_cached_size(&self) -> u32
Get size previously computed by compute_size.
fn get_unknown_fields<'s>(&'s self) -> &'s UnknownFields
Get a reference to unknown fields.
fn mut_unknown_fields<'s>(&'s mut self) -> &'s mut UnknownFields
Get a mutable reference to unknown fields.
fn as_any(&self) -> &Any
View self as Any.
fn new() -> Self where
Self: Sized,
Self: Sized,
Create an empty message object.
fn default_instance() -> &'static Self where
Self: Sized,
Self: Sized,
Return a pointer to default immutable message.
Provided Methods
fn write_to(&self, os: &mut CodedOutputStream) -> ProtobufResult<()>
Write the message to the stream.
Results in error if message is not fully initialized.
fn write_length_delimited_to(
&self,
os: &mut CodedOutputStream
) -> ProtobufResult<()>
&self,
os: &mut CodedOutputStream
) -> ProtobufResult<()>
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>) -> ProtobufResult<()>
Write the message to the vec, prepend the message with message length encoded as varint.
fn merge_from_bytes(&mut self, bytes: &[u8]) -> ProtobufResult<()>
Update this message object with fields read from given stream.
fn check_initialized(&self) -> ProtobufResult<()>
Check if all required fields of this object are initialized.
fn write_to_writer(&self, w: &mut Write) -> ProtobufResult<()>
Write the message to the writer.
fn write_to_vec(&self, v: &mut Vec<u8>) -> ProtobufResult<()>
Write the message to bytes vec.
fn write_to_bytes(&self) -> ProtobufResult<Vec<u8>>
Write the message to bytes vec.
fn write_length_delimited_to_writer(&self, w: &mut Write) -> ProtobufResult<()>
Write the message to the writer, prepend the message with message length encoded as varint.
fn write_length_delimited_to_bytes(&self) -> ProtobufResult<Vec<u8>>
Write the message to the bytes vec, prepend the message with message length encoded as varint.
fn type_id(&self) -> TypeId
Get type id for downcasting.
fn as_any_mut(&mut self) -> &mut Any
View self as mutable Any.
fn into_any(self: Box<Self>) -> Box<Any>
Convert boxed self to boxed Any.
fn descriptor_static() -> &'static MessageDescriptor where
Self: Sized,
Self: Sized,
Get message descriptor for message type.
Implementors
impl Message for FileDescriptorSetimpl Message for FileDescriptorProtoimpl Message for DescriptorProtoimpl Message for DescriptorProto_ExtensionRangeimpl Message for DescriptorProto_ReservedRangeimpl Message for FieldDescriptorProtoimpl Message for OneofDescriptorProtoimpl Message for EnumDescriptorProtoimpl Message for EnumValueDescriptorProtoimpl Message for ServiceDescriptorProtoimpl Message for MethodDescriptorProtoimpl Message for FileOptionsimpl Message for MessageOptionsimpl Message for FieldOptionsimpl Message for OneofOptionsimpl Message for EnumOptionsimpl Message for EnumValueOptionsimpl Message for ServiceOptionsimpl Message for MethodOptionsimpl Message for UninterpretedOptionimpl Message for UninterpretedOption_NamePartimpl Message for SourceCodeInfoimpl Message for SourceCodeInfo_Locationimpl Message for GeneratedCodeInfoimpl Message for GeneratedCodeInfo_Annotationimpl Message for CodeGeneratorRequestimpl Message for CodeGeneratorResponseimpl Message for CodeGeneratorResponse_Fileimpl Message for Anyimpl Message for Apiimpl Message for Methodimpl Message for Mixinimpl Message for Durationimpl Message for Emptyimpl Message for FieldMaskimpl Message for SourceContextimpl Message for Structimpl Message for Valueimpl Message for ListValueimpl Message for Timestampimpl Message for Typeimpl Message for Fieldimpl Message for Enumimpl Message for EnumValueimpl Message for Optionimpl Message for DoubleValueimpl Message for FloatValueimpl Message for Int64Valueimpl Message for UInt64Valueimpl Message for Int32Valueimpl Message for UInt32Valueimpl Message for BoolValueimpl Message for StringValueimpl Message for BytesValue