Trait Message

Source
pub trait Message {
    // Required method
    fn typename() -> &'static str;

    // Provided methods
    fn to_map(&self) -> Result<Map<String, Value>, Error>
       where Self: Serialize + Sized { ... }
    fn from_map(map: &Map<String, Value>) -> Result<Self, Error>
       where Self: DeserializeOwned { ... }
}
Expand description

A trait that must be implemented by all messages.

Messages sent to and received from Google Cloud services may be wrapped in Any. Any uses a @type field to encoding the type name and then validates extraction and insertion against this type.

Required Methods§

Source

fn typename() -> &'static str

The typename of this message.

Provided Methods§

Source

fn to_map(&self) -> Result<Map<String, Value>, Error>
where Self: Serialize + Sized,

Store the value into a JSON object.

Source

fn from_map(map: &Map<String, Value>) -> Result<Self, Error>
where Self: DeserializeOwned,

Extract the value from a JSON object.

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§