Expand description
Codec Registry — compression/encoding codec selection and peer negotiation
Tensor data flows through multiple compression/encoding stages. This module manages codec selection and negotiation between peers so that both sides agree on a common codec before data is transmitted.
§Overview
CodecRegistry is the central store of CodecDescriptor entries, each
keyed by a CodecId. Seven built-in codecs are pre-registered on
construction:
| Id | Name | Speed class | Ratio est. |
|---|---|---|---|
| 0 | none | VeryFast | 1.00 |
| 1 | zstd | Balanced | 0.30 |
| 2 | lz4 | VeryFast | 0.55 |
| 3 | snappy | VeryFast | 0.60 |
| 4 | brotli | Slow | 0.25 |
| 10 | arrow_ipc | Fast | 0.70 |
| 11 | garw | Fast | 0.40 |
Codec negotiation follows a “first-match” policy: the first codec in the local preference list that is also present in the remote list wins.
§Examples
use ipfrs_tensorlogic::codec_registry::{CodecId, CodecRegistry};
let registry = CodecRegistry::new();
// Look up ZSTD
let desc = registry.get(CodecId::ZSTD).expect("example: should succeed in docs");
assert_eq!(desc.name, "zstd");
// Negotiate between two peers
let local = vec![CodecId::ZSTD, CodecId::LZ4, CodecId::NONE];
let remote = vec![CodecId::LZ4, CodecId::NONE];
let agreed = CodecRegistry::negotiate(&local, &remote);
assert_eq!(agreed, Some(CodecId::LZ4));Structs§
- Codec
Descriptor - Metadata about a single codec.
- CodecId
- Opaque identifier for a compression/encoding codec.
- Codec
Negotiation Record - Record of a single codec negotiation between the local peer and a remote peer.
- Codec
Registry - Central registry of compression/encoding codecs.
Enums§
- Codec
Error - Errors that can occur while working with
CodecRegistry. - Speed
Class - Qualitative speed tier for a codec.