Trait mz_persist_types::Codec64
source · pub trait Codec64:
Sized
+ Clone
+ 'static {
// Required methods
fn codec_name() -> String;
fn encode(&self) -> [u8; 8];
fn decode(buf: [u8; 8]) -> Self;
}
Expand description
Encoding and decoding operations for a type usable as a persisted timestamp or diff.
Required Methods§
sourcefn codec_name() -> String
fn codec_name() -> String
Name of the codec.
This name is stored for the timestamp and diff when a stream is first created and the same timestamp and diff codec must be used for that stream afterward.
sourcefn encode(&self) -> [u8; 8]
fn encode(&self) -> [u8; 8]
Encode a timestamp or diff for permanent storage.
This must perfectly round-trip Self through Codec64::decode. If the encode function for this codec ever changes, decode must be able to handle bytes output by all previous versions of encode.
sourcefn decode(buf: [u8; 8]) -> Self
fn decode(buf: [u8; 8]) -> Self
Decode a timestamp or diff previous encoded with this codec’s Codec64::encode.
This must perfectly round-trip Self through Codec64::encode. If the encode function for this codec ever changes, decode must be able to handle bytes output by all previous versions of encode.