Preview of the proposed up-rust native-frame-model branch (up-rust b6b99c6d, up-spec f0e9b17) — not released documentation. branch · write-up

Trait ProtobufMappable

Source
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§

Source

fn parse_from_protobuf_bytes(proto: &[u8]) -> Result<Self, SerializationError>

Parses an instance of this type from the given protobuf bytes.

§Arguments
  • proto - The protobuf message.
§Errors

Returns an error if the given bytes cannot be parsed as a protobuf.

Source

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.

Source

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.

Source

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§

Source§

impl ProtobufMappable for UAttributes

Source§

impl ProtobufMappable for UMessage

Source§

impl ProtobufMappable for UStatus

Source§

impl ProtobufMappable for UUID

Source§

impl ProtobufMappable for UUri

Source§

impl<T: MessageFull> ProtobufMappable for T

Blanket implementation for all types that have been generated by the protobuf crate.