Expand description
Pure Rust implementation of AT Protocol repository structures.
This crate provides:
- MST (Merkle Search Tree) encoding/decoding
- Repository structures for commits, records, and operations
CAR v1 serialization, block storage, and varint encoding have been moved
to the atproto-dasl crate. Types are re-exported here for backward
compatibility.
§Features
- Pure Rust implementation (no external MST dependencies)
- Built on
atproto-daslfor DAG-CBOR encoding, CAR, and storage - Async-first streaming design using tokio
- Configurable CID and signature verification
- Memory limits for DoS prevention
- Pluggable storage backends (memory, disk, hybrid)
§Example Usage
ⓘ
use atproto_repo::{CarReader, RepoConfig, MemoryStorage};
use tokio::fs::File;
async fn example() -> anyhow::Result<()> {
// Read a CAR file
let file = File::open("repo.car").await?;
let reader = CarReader::new(file).await?;
println!("Roots: {:?}", reader.roots());
// Stream blocks into storage
let mut storage = MemoryStorage::new();
reader.stream_to_storage(&mut storage).await?;
Ok(())
}§Specifications
Re-exports§
pub use errors::MstError;pub use errors::RepoError;pub use mst::Mst;pub use mst::MstDiff;pub use mst::MstNode;pub use mst::TreeEntry;pub use repo::Commit;pub use repo::DiskRepository;pub use repo::MemoryRepository;pub use repo::RecordPath;pub use repo::Repository;
Modules§
- errors
- Error types for AT Protocol repository operations.
- mst
- Merkle Search Tree (MST) implementation.
- repo
- AT Protocol repository structures.
Structs§
- CarBlock
- A single block in a CAR file.
- CarConfig
- Configuration for CAR file operations with verification and limits.
- CarHeader
- CAR v1 header structure.
- CarReader
- Async streaming CAR v1 reader.
- CarWriter
- Async streaming CAR v1 writer.
- Disk
Storage - Hybrid storage that keeps hot data in memory and spills to disk.
- Limits
Config - Memory and resource limits for low-resource environments.
- Memory
Storage - In-memory block storage with configurable limits.
- Repo
Config - Configuration for repository operations with verification and limits.
- Spillable
Buffer - A buffer that writes to memory until a threshold, then spills to disk.
Enums§
- CarError
- Errors during CAR file operations.
- Spillable
Reader - Reader for consuming data from a SpillableBuffer.
- Storage
Error - Errors during storage operations.
- Varint
Error - Errors during varint encoding/decoding.
Constants§
- DAG_
CBOR_ CODEC - DAG-CBOR multicodec identifier (0x71).
- SHA256_
CODE - SHA-256 multihash code (0x12).
Traits§
- Block
Storage - Trait for block storage backends.
Functions§
- compute_
cid - Compute a CIDv1 with dag-cbor codec and sha2-256 hash.