AnyConvertible

Trait AnyConvertible 

Source
pub trait AnyConvertible: Sized {
    // Required methods
    fn to_any(&self) -> Result<Any, ExtensionError>;
    fn from_any<'a>(any: AnyRef<'a>) -> Result<Self, ExtensionError>;
    fn type_url() -> String;
}
Expand description

Trait for types that can be converted to/from protobuf Any messages. Note that this is already implemented for all prost::Message types. For custom types, implement this trait.

Required Methods§

Source

fn to_any(&self) -> Result<Any, ExtensionError>

Convert this type to a protobuf Any message

Source

fn from_any<'a>(any: AnyRef<'a>) -> Result<Self, ExtensionError>

Convert from a protobuf Any message to this type

Source

fn type_url() -> String

Get the protobuf type URL for this type. For prost::Message types, this is provided automatically via blanket impl. Custom types must implement this method.

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<T> AnyConvertible for T
where T: Message + Name + Default,