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§

source

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.

source

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.

source

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Codec64 for i64

source§

fn codec_name() -> String

source§

fn encode(&self) -> [u8; 8]

source§

fn decode(buf: [u8; 8]) -> Self

source§

impl Codec64 for u64

source§

fn codec_name() -> String

source§

fn encode(&self) -> [u8; 8]

source§

fn decode(buf: [u8; 8]) -> Self

source§

impl Codec64 for Product<u32, u32>

source§

fn codec_name() -> String

source§

fn encode(&self) -> [u8; 8]

source§

fn decode(buf: [u8; 8]) -> Self

Implementors§