pub trait Codec:
Sized
+ Default
+ Send
+ Sync
+ 'static {
// Required methods
fn encode<T>(&self, task: &T) -> Result<Vec<u8>, ()>
where T: Serialize;
fn encode_into<T>(&self, task: &T, buf: &mut Vec<u8>) -> Result<usize, ()>
where T: Serialize;
fn decode<'a, T>(&self, buf: &'a [u8]) -> Result<T, ()>
where T: Deserialize<'a>;
}Expand description
Interface for occams-rpc-codec
The codec is immutable, if need changing (like setting up cipher), should have inner mutablilty
Required Methods§
fn encode<T>(&self, task: &T) -> Result<Vec<u8>, ()>where
T: Serialize,
Sourcefn encode_into<T>(&self, task: &T, buf: &mut Vec<u8>) -> Result<usize, ()>where
T: Serialize,
fn encode_into<T>(&self, task: &T, buf: &mut Vec<u8>) -> Result<usize, ()>where
T: Serialize,
sererialized the msg into buf (with std::io::Writer), and return the size written
fn decode<'a, T>(&self, buf: &'a [u8]) -> Result<T, ()>where
T: Deserialize<'a>,
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.