pub trait CacheCodec:
Send
+ Sync
+ Clone
+ 'static {
const CODEC_ID: u8 = envelope::CODEC_USER;
// Required methods
fn encode(&self, entry: &CacheEntry) -> Result<Vec<u8>, CacheError>;
fn decode(&self, bytes: &[u8]) -> Result<CacheEntry, CacheError>;
}Expand description
Provided Associated Constants§
Sourceconst CODEC_ID: u8 = envelope::CODEC_USER
const CODEC_ID: u8 = envelope::CODEC_USER
Identifies this codec in byte 4 of the envelope header.
Entries are only decoded by a codec whose CODEC_ID matches the byte
recorded when they were written; a mismatch is reported as a miss rather
than decoded with the wrong codec.
0x00..=0x7F is reserved for this crate (0x01 is
PostcardCodec). 0x80..=0xFF is free for downstream codecs, and
the default value is envelope::CODEC_USER (0x80).
Required Methods§
fn encode(&self, entry: &CacheEntry) -> Result<Vec<u8>, CacheError>
fn decode(&self, bytes: &[u8]) -> Result<CacheEntry, CacheError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".