Skip to main content

Crate proto_blue_repo

Crate proto_blue_repo 

Source
Expand description

AT Protocol repository: MST, CAR files, commits, block storage.

Implements the Merkle Search Tree (MST) used for AT Protocol repositories, CAR file encoding/decoding, and block storage abstractions.

§Examples

use proto_blue_repo::{MstNode, BlockMap, CidSet, blocks_to_car, read_car};
use proto_blue_lex_data::LexValue;
use proto_blue_lex_cbor::cid_for_lex;
use std::collections::BTreeMap;

// Create a value and compute its CID
let mut map = BTreeMap::new();
map.insert("text".into(), LexValue::String("Hello!".into()));
let cid = cid_for_lex(&LexValue::Map(map)).unwrap();

// Build an MST (immutable, copy-on-write)
let mst = MstNode::empty();
let mst = mst.add("app.bsky.feed.post/abc123", cid.clone()).unwrap();
assert_eq!(mst.leaves().len(), 1);

// BlockMap for storing CID -> bytes
let mut blocks = BlockMap::new();
blocks.set(cid.clone(), vec![1, 2, 3]);
assert_eq!(blocks.len(), 1);

// CidSet for tracking seen CIDs
let mut seen = CidSet::new();
seen.add(cid.clone());
assert!(seen.has(&cid));

Re-exports§

pub use block_map::BlockMap;
pub use car::CarBlock;
pub use car::ReadCarOpts;
pub use car::blocks_to_car;
pub use car::read_car;
pub use car::read_car_opts;
pub use car::read_car_with_root;
pub use cid_set::CidSet;
pub use commit::COMMIT_VERSION;
pub use commit::SignedCommit;
pub use commit::UnsignedCommit;
pub use commit::ensure_commit_sig;
pub use commit::sign_commit;
pub use commit::verify_commit_sig;
pub use data_diff::DataAdd;
pub use data_diff::DataDelete;
pub use data_diff::DataDiff;
pub use data_diff::DataUpdate;
pub use data_key::DataKey;
pub use data_key::DataKeyError;
pub use data_key::format_data_key;
pub use data_key::parse_data_key;
pub use error::RepoError;
pub use firehose::AccountEvent;
pub use firehose::CommitEvent;
pub use firehose::FirehoseEvent;
pub use firehose::IdentityEvent;
pub use firehose::InfoEvent;
pub use firehose::RepoOp;
pub use firehose::RepoOpAction;
pub use firehose::SyncEvent;
pub use firehose::decode_event;
pub use firehose_client::Firehose;
pub use mst::Leaf;
pub use mst::MstNode;
pub use mst::NodeEntry;
pub use proofs::RecordCidClaim;
pub use proofs::commit_proof;
pub use proofs::covering_proof;
pub use proofs::proof_for_key;
pub use proofs::proof_for_left_sibling;
pub use proofs::proof_for_right_sibling;
pub use proofs::verify_claims;
pub use proofs::verify_key_in_proof;
pub use repo::CommitData;
pub use repo::Repo;
pub use repo::RepoWrite;
pub use storage::MemoryBlockstore;
pub use storage::RepoStorage;
pub use sync::VerifiedDiff;
pub use sync::VerifiedRepo;
pub use sync::verify_diff_car;
pub use sync::verify_repo;
pub use sync::verify_repo_car;

Modules§

block_map
BlockMap — a map from CID to block bytes.
car
CAR (Content Addressable aRchive) file reading and writing.
cid_set
CID set — a set of content identifiers.
commit
Signed commits — the root of an AT Protocol repository.
data_diff
Diff two MSTs into structured add/update/delete lists.
data_key
Parse and format MST keys of the form <nsid>/<rkey>.
error
Error types for the repository system.
firehose
Firehose event decoding.
firehose_client
Firehose WebSocket client.
mst
Merkle Search Tree implementation for AT Protocol repositories.
proofs
Merkle proofs over an MST.
repo
Writable repository: the read-write counterpart to crate::sync::VerifiedRepo.
storage
Block storage trait + in-memory implementation.
sync
Repo sync: parse and verify full-repo CAR files, diff commits.