Skip to main content

Module codec_registry

Module codec_registry 

Source
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:

IdNameSpeed classRatio est.
0noneVeryFast1.00
1zstdBalanced0.30
2lz4VeryFast0.55
3snappyVeryFast0.60
4brotliSlow0.25
10arrow_ipcFast0.70
11garwFast0.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§

CodecDescriptor
Metadata about a single codec.
CodecId
Opaque identifier for a compression/encoding codec.
CodecNegotiationRecord
Record of a single codec negotiation between the local peer and a remote peer.
CodecRegistry
Central registry of compression/encoding codecs.

Enums§

CodecError
Errors that can occur while working with CodecRegistry.
SpeedClass
Qualitative speed tier for a codec.