vecdb_derive
Derive macros for vecdb to enable custom types in compressed and uncompressed vectors.
Provides two derive macros:
#[derive(Bytes)]- For use withBytesVec,LZ4Vec,ZstdVec#[derive(Pco)]- For use withPcoVec(compressed numeric vectors)
Install
Usage
Bytes Derive
Use #[derive(Bytes)] to enable custom wrapper types with uncompressed or general-purpose compressed vectors:
use ;
;
;
Requirements:
- Must be a tuple struct with exactly one field
- Inner type must implement
Bytes - Works with generic types
Pco Derive
Use #[derive(Pco)] for numeric wrapper types to enable Pcodec compression:
use ;
;
;
Requirements:
- Must be a tuple struct with exactly one field
- Inner type must implement
Pco(numeric types only: u16-u64, i16-i64, f32, f64) - The derive automatically implements both
BytesandPcotraits - Works with generic types
Generic Types
Both derives support generic type parameters:
use ;
// Generic wrapper with Bytes
;
// Generic wrapper with Pco
;
// Nested generics
;
// Use with concrete types
let value = Wrapper;
let numeric = NumericWrapper;
let nested = Container;
The derives automatically add appropriate trait bounds (T: Bytes or T: Pco) to the generated implementations.
How It Works
Both derives implement traits by delegating to the inner type:
// #[derive(Bytes)] generates:
// #[derive(Pco)] generates:
// - Bytes implementation (same as above)
// - Pco implementation with NumberType from inner type
// - TransparentPco marker trait
This allows wrapper types to have the same serialization and compression characteristics as their inner type.