pub trait Serializer<T> {
// Required methods
fn serialize(&self, data_to_serialize: &T) -> SerializerResult<Box<[u8]>>;
fn deserialize<'a, R: Read + Unpin + 'a>(
&self,
reader: R,
) -> Box<dyn Stream<Item = SerializerResult<T>> + Unpin + 'a>
where T: 'a;
}
Expand description
Serializer trait
This methods defines how to serialize and deserialize transactions and the snapshoted data. You can implement it to have your logs in whaetever format that you like.
Required Methods§
Sourcefn serialize(&self, data_to_serialize: &T) -> SerializerResult<Box<[u8]>>
fn serialize(&self, data_to_serialize: &T) -> SerializerResult<Box<[u8]>>
Serialize method. It receives a reference to a data and it should return a boxed byte array with the serialized result.
The redolog will consist of appending multiple calls to this method. The snapshot will be a single file with the result of one call to this method.
Sourcefn deserialize<'a, R: Read + Unpin + 'a>(
&self,
reader: R,
) -> Box<dyn Stream<Item = SerializerResult<T>> + Unpin + 'a>where
T: 'a,
fn deserialize<'a, R: Read + Unpin + 'a>(
&self,
reader: R,
) -> Box<dyn Stream<Item = SerializerResult<T>> + Unpin + 'a>where
T: 'a,
Deserialize method. It receives a reader to the redolog (or snapshot), and it should return a stream of deserialized data
In the case of the redolog, it will execute all transactions returned in the stream. If it is a snaphot, only the first item will be used.
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.