Skip to main content

Crate atproto_repo

Crate atproto_repo 

Source
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-dasl for 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.
DiskStorage
Hybrid storage that keeps hot data in memory and spills to disk.
LimitsConfig
Memory and resource limits for low-resource environments.
MemoryStorage
In-memory block storage with configurable limits.
RepoConfig
Configuration for repository operations with verification and limits.
SpillableBuffer
A buffer that writes to memory until a threshold, then spills to disk.

Enums§

CarError
Errors during CAR file operations.
SpillableReader
Reader for consuming data from a SpillableBuffer.
StorageError
Errors during storage operations.
VarintError
Errors during varint encoding/decoding.

Constants§

DAG_CBOR_CODEC
DAG-CBOR multicodec identifier (0x71).
SHA256_CODE
SHA-256 multihash code (0x12).

Traits§

BlockStorage
Trait for block storage backends.

Functions§

compute_cid
Compute a CIDv1 with dag-cbor codec and sha2-256 hash.