Skip to main content

Serializer

Trait Serializer 

Source
pub trait Serializer: Send + Sync {
    // Required methods
    fn serialize<T>(&self, value: &T) -> Result<Vec<u8>, ProtocolError>
       where T: Serialize;
    fn deserialize<T>(&self, bytes: &[u8]) -> Result<T, ProtocolError>
       where T: DeserializeOwned;
    fn serialize_request(&self, req: &Request) -> Result<Vec<u8>, ProtocolError>;
    fn deserialize_request(
        &self,
        bytes: &[u8],
    ) -> Result<Request, ProtocolError>;
    fn serialize_response(
        &self,
        resp: &Response,
    ) -> Result<Vec<u8>, ProtocolError>;
    fn deserialize_response(
        &self,
        bytes: &[u8],
    ) -> Result<Response, ProtocolError>;
    fn serialize_error(
        &self,
        err: &ErrorMessage,
    ) -> Result<Vec<u8>, ProtocolError>;
    fn deserialize_error(
        &self,
        bytes: &[u8],
    ) -> Result<ErrorMessage, ProtocolError>;
}

Required Methods§

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§