Trait prevayler_rs::serializer::Serializer [−][src]
pub trait Serializer<T> { 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; }
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
fn serialize(&self, data_to_serialize: &T) -> SerializerResult<Box<[u8]>>
[src]
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.
fn deserialize<'a, R: Read + Unpin + 'a>(
&self,
reader: R
) -> Box<dyn Stream<Item = SerializerResult<T>> + Unpin + 'a> where
T: 'a,
[src]
&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.
Implementors
impl<T> Serializer<T> for JsonSerializer where
T: Serialize + DeserializeOwned + Unpin,
[src]
impl<T> Serializer<T> for JsonSerializer where
T: Serialize + DeserializeOwned + Unpin,
[src]fn serialize(&self, data_to_serialize: &T) -> SerializerResult<Box<[u8]>>
[src]
fn deserialize<'a, R: Read + Unpin + 'a>(
&self,
reader: R
) -> Box<dyn Stream<Item = SerializerResult<T>> + Unpin + 'a> where
T: 'a,
[src]
&self,
reader: R
) -> Box<dyn Stream<Item = SerializerResult<T>> + Unpin + 'a> where
T: 'a,