Trait request_response::Serializable
source · pub trait Serializable: Sized {
// Required methods
fn to_bytes(&self) -> Result<Vec<u8>>;
fn from_bytes(bytes: &[u8]) -> Result<Self>;
}
Expand description
Required Methods§
sourcefn to_bytes(&self) -> Result<Vec<u8>>
fn to_bytes(&self) -> Result<Vec<u8>>
Serialize the type to a byte array. If this is for a Request
and your Request
type
is represented as an enum, please make sure that you serialize it with a unique type ID. Otherwise,
you may end up with collisions as the request hash is used as a unique identifier
§Errors
- If the type cannot be serialized to a byte array
sourcefn from_bytes(bytes: &[u8]) -> Result<Self>
fn from_bytes(bytes: &[u8]) -> Result<Self>
Deserialize the type from a byte array
§Errors
- If the byte array is not a valid representation of the type
Object Safety§
This trait is not object safe.
Implementors§
impl<R: Request> Serializable for ResponseMessage<R>
impl<R: Request, K: SignatureKey> Serializable for Message<R, K>
A blanket implementation of the Serializable
trait for any Message