#[derive(Pco)]Expand description
Derives the Pco trait for single-field tuple structs containing numeric types.
This macro enables custom wrapper types to work with PcoVec for compressed storage
of numeric data using Pcodec compression.
§Requirements
- Must be a tuple struct with exactly one field
- The inner type must implement
Pco(numeric types: u16-u64, i16-i64, f32, f64) - Supports generic type parameters
§Generated Implementation
The derive generates three trait implementations:
Bytes- For serialization (same as#[derive(Bytes)])Pco- Specifies the numeric type for compressionTransparentPco- Marker trait for transparent wrappers
ⓘ
impl Pco for Wrapper<T> where T: Pco + Bytes {
type NumberType = <T as Pco>::NumberType;
}
impl TransparentPco<<T as Pco>::NumberType> for Wrapper<T>
where T: Pco + Bytes {}
impl Bytes for Wrapper<T> where T: Pco + Bytes {
// ... same as Bytes derive
}The NumberType is automatically propagated from the inner type, ensuring the
wrapper has the same compression characteristics.
§Example
ⓘ
use vecdb::{Pco, PcoVec};
#[derive(Pco)]
struct Price(f64);
#[derive(Pco)]
struct NumericWrapper<T>(T); // Generic types supported
// Nested generics work too
#[derive(Pco)]
struct Container<T>(NumericWrapper<T>);