Anda DB Utils
anda_db_utils is a utility Rust library for Anda DB, providing helpful extensions and data structures.
Features
PipeTrait: Enables functional-style method chaining.UniqueVec<T>: AVecthat ensures all its elements are unique.CountingWriter: A writer that counts bytes, useful for determining the size of serialized data without allocation.
Usage
Pipe Trait
The Pipe trait allows you to chain functions in a fluent, readable way.
use Pipe;
let result = 5.pipe.pipe;
assert_eq!;
UniqueVec
UniqueVec<T> is a vector that automatically handles uniqueness of its elements, backed by a HashSet for efficiency.
use UniqueVec;
let mut unique_vec = from;
// Pushing an existing item does nothing
unique_vec.push;
assert_eq!;
// Pushing a new item adds it to the vector
unique_vec.push;
assert_eq!;
// Extend with a mix of new and existing items
unique_vec.extend;
assert_eq!;
CountingWriter
CountingWriter can be used to calculate the size of data when serialized, for example with CBOR, without actually writing to memory.
use CountingWriter;
use Serialize;
let data = MyData ;
let size = estimate_cbor_size;
println!;
License
Copyright © 2025 LDC Labs.
ldclabs/anda-db is licensed under the MIT License. See LICENSE for the full license text.