KotobaDB Core
Core traits, data structures, and transaction logic for KotobaDB. This crate provides the foundational types and interfaces that all KotobaDB implementations must satisfy.
Overview
kotoba-db-core defines the fundamental abstractions that make KotobaDB work:
- Data Types:
Value,Block,NodeBlock,EdgeBlock,Cid - Storage Engine:
StorageEnginetrait for pluggable backends - Serialization: CBOR-based binary serialization with content addressing
Data Types
Value
The fundamental data type for all properties and values:
Block
Content-addressed data blocks:
CID (Content Identifier)
Cryptographic content identifier using BLAKE3:
;
Storage Engine Trait
The core abstraction for pluggable storage backends:
Extension Methods
The trait provides convenient methods for working with content-addressed blocks:
Node and Edge Structures
NodeBlock
Represents a graph node with properties:
EdgeBlock
Represents a graph edge between nodes:
Content Addressing
All blocks are content-addressed using CID:
Usage Examples
Implementing a Storage Engine
use ;
Working with Blocks
use ;
use BTreeMap;
// Create a node
let mut properties = new;
properties.insert;
properties.insert;
let node = NodeBlock ;
let block = Node;
// Compute CID
let cid = block.cid?;
// Serialize
let bytes = block.to_bytes?;
// Deserialize
let restored_block = from_bytes?;
Architecture
This crate is designed to be:
- Minimal: Only essential types and traits
- Extensible: Easy to implement custom storage engines
- Performance-oriented: Efficient serialization and content addressing
- Safe: Memory-safe Rust with comprehensive error handling
Dependencies
serde: Serialization frameworkciborium: CBOR serializationblake3: Cryptographic hashingasync-trait: Async trait supportanyhow: Error handling
Testing
License
Licensed under the MIT License.