Trait MessageExt

Source
pub trait MessageExt: Message {
    // Required method
    fn to_bytes(&self) -> Result<Vec<u8>, EncodeError>;

    // Provided methods
    fn from_any(any: &Any) -> Result<Self, DecodeError>
       where Self: Default + Sized + TypeUrl { ... }
    fn to_any(&self) -> Result<Any, EncodeError>
       where Self: TypeUrl { ... }
}
Expand description

Extension trait for Message.

Required Methods§

Source

fn to_bytes(&self) -> Result<Vec<u8>, EncodeError>

Serialize this protobuf message as a byte vector.

Provided Methods§

Source

fn from_any(any: &Any) -> Result<Self, DecodeError>
where Self: Default + Sized + TypeUrl,

Parse this message proto from Any.

Source

fn to_any(&self) -> Result<Any, EncodeError>
where Self: TypeUrl,

Serialize this message proto as Any.

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<M> MessageExt for M
where M: Message,