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§
Sourcefn to_json(&self) -> Result<String, MessageFormatError>
fn to_json(&self) -> Result<String, MessageFormatError>
Convert to json.
Sourcefn to_base64(&self) -> Result<String, MessageFormatError>
fn to_base64(&self) -> Result<String, MessageFormatError>
Convert to base64.
Sourcefn from_binary(msg: &[u8]) -> Result<Self, MessageFormatError>
fn from_binary(msg: &[u8]) -> Result<Self, MessageFormatError>
Convert from binary.
Sourcefn from_json(msg: &str) -> Result<Self, MessageFormatError>
fn from_json(msg: &str) -> Result<Self, MessageFormatError>
Convert from json.
Sourcefn from_base64(msg: &str) -> Result<Self, MessageFormatError>
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.