Trait koit::format::Format [−][src]
pub trait Format<T>: Sized { type Error: Error + Send + Sync + 'static; fn to_bytes(value: &T) -> Result<Vec<u8>, Self::Error>; fn from_bytes(data: Vec<u8>) -> Result<T, Self::Error>; }
Expand description
Trait implementable by format providers.
By implementing this trait, a type becomes a marker for the specified format. That type can then be used for formatting (without instantiating an object of that type).
Associated Types
Loading content...Required methods
fn to_bytes(value: &T) -> Result<Vec<u8>, Self::Error>
[src]
Expand description
Convert data to bytes.
Errors
If the data failed to be encoded by the format, an error variant is returned.
fn from_bytes(data: Vec<u8>) -> Result<T, Self::Error>
[src]
Expand description
Convert bytes to data.
Errors
If the bytes failed to be decoded by the format, an error variant is returned.
Implementors
impl<T: DeserializeOwned + Serialize> Format<T> for Json
[src]
impl<T: DeserializeOwned + Serialize> Format<T> for Json
[src]