Expand description
Shared encoding utilities for key-value serialization.
This module provides common encoding/decoding primitives used by OpenData storage systems.
§Why Encode/Decode Traits Are Not Defined Here
Rust’s orphan rules prevent implementing a trait for a type when both the trait AND the type are defined in external crates. This prevents conflicting implementations across the ecosystem.
For example, if we defined Encode here in common, then timeseries
couldn’t implement common::Encode for u32 or SeriesId (which is a type
alias for u32) because:
Encodewould be foreign totimeseries(defined incommon)u32is foreign to both (defined instd)
The rule is: at least one of {trait, type} must be local to the crate doing the implementation.
Therefore, each storage crate (timeseries, vector) defines its own
Encode/Decode traits locally, allowing them to implement these traits
for primitives and type aliases. The generic functions like encode_array
must also be defined locally since they’re bounded by the local traits.
Structs§
- Encoding
Error - Encoding error with a descriptive message.
Functions§
- decode_
array_ count - Decode the count prefix of an array.
- decode_
optional_ utf8 - Decode an optional non-empty UTF-8 string.
- decode_
u64 - Decode a u64 value from 8-byte little-endian.
- decode_
utf8 - Decode a UTF-8 string.
- encode_
array_ count - Encode the count prefix of an array.
- encode_
optional_ utf8 - Encode an optional non-empty UTF-8 string.
- encode_
u64 - Encode a u64 value as 8-byte little-endian.
- encode_
utf8 - Encode a UTF-8 string.
- validate_
fixed_ element_ array_ len - Validate that a buffer length is divisible by the element size for fixed-element arrays.