Trait MessageFormat

Source
pub trait MessageFormat: Sized {
    // Required methods
    fn to_binary(&self) -> Result<Vec<u8>, MessageFormatError>;
    fn to_json(&self) -> Result<String, MessageFormatError>;
    fn to_base64(&self) -> Result<String, MessageFormatError>;
    fn from_binary(msg: &[u8]) -> Result<Self, MessageFormatError>;
    fn from_json(msg: &str) -> Result<Self, MessageFormatError>;
    fn from_base64(msg: &str) -> Result<Self, MessageFormatError>;
}
Expand description

Trait for converting to/from binary/json/base64.

Required Methods§

Source

fn to_binary(&self) -> Result<Vec<u8>, MessageFormatError>

Convert to binary.

Source

fn to_json(&self) -> Result<String, MessageFormatError>

Convert to json.

Source

fn to_base64(&self) -> Result<String, MessageFormatError>

Convert to base64.

Source

fn from_binary(msg: &[u8]) -> Result<Self, MessageFormatError>

Convert from binary.

Source

fn from_json(msg: &str) -> Result<Self, MessageFormatError>

Convert from json.

Source

fn from_base64(msg: &str) -> Result<Self, MessageFormatError>

Convert from base64.

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§