pub trait ProtobufMappable: Sized {
// Required methods
fn parse_from_protobuf_bytes(
proto: &[u8],
) -> Result<Self, SerializationError>;
fn parse_from_packed_protobuf_bytes(
proto: &[u8],
) -> Result<Self, SerializationError>;
fn write_to_protobuf_bytes(&self) -> Result<Vec<u8>, SerializationError>;
fn write_to_packed_protobuf_bytes(
&self,
) -> Result<Vec<u8>, SerializationError>;
}Expand description
Role: standalone utility letting protobuf-generated types ride as payloads implicitly; blanket-implemented for protobuf types — see the trait map.
A type that can be mapped to and from a protobuf.
Required Methods§
Sourcefn parse_from_protobuf_bytes(proto: &[u8]) -> Result<Self, SerializationError>
fn parse_from_protobuf_bytes(proto: &[u8]) -> Result<Self, SerializationError>
Sourcefn parse_from_packed_protobuf_bytes(
proto: &[u8],
) -> Result<Self, SerializationError>
fn parse_from_packed_protobuf_bytes( proto: &[u8], ) -> Result<Self, SerializationError>
Parses an instance of this type from the given packed protobuf bytes.
§Arguments
proto- The protobuf Any message containing the actual message packed inside.
§Errors
Returns an error if the given bytes cannot be parsed to a protobuf Any message or if the contained message cannot be unpacked to the expected type.
Sourcefn write_to_protobuf_bytes(&self) -> Result<Vec<u8>, SerializationError>
fn write_to_protobuf_bytes(&self) -> Result<Vec<u8>, SerializationError>
Serializes this instance to protobuf bytes.
§Errors
Returns an error if this instance cannot be serialized to protobuf bytes.
Sourcefn write_to_packed_protobuf_bytes(&self) -> Result<Vec<u8>, SerializationError>
fn write_to_packed_protobuf_bytes(&self) -> Result<Vec<u8>, SerializationError>
Serializes this instance to packed protobuf bytes.
§Errors
Returns an error if this instance cannot be serialized to packed protobuf bytes.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl ProtobufMappable for UAttributes
impl ProtobufMappable for UMessage
impl ProtobufMappable for UStatus
impl ProtobufMappable for UUID
impl ProtobufMappable for UUri
impl<T: MessageFull> ProtobufMappable for T
Blanket implementation for all types that have been generated by the protobuf crate.