pub struct Node {
pub level: u32,
pub l: Option<Box<Node>>,
pub entries: Vec<NodeEntry>,
}Expand description
An in-memory MST over an account repo’s records (all collections, keyed by
<collection>/<rkey>).
Internally this is a recursive structure of Nodes, each at a level.
The tree shape depends only on the (key → record-CID) map, not insertion
order, so any host with the same records builds the same root.
Fields§
§level: u32§l: Option<Box<Node>>§entries: Vec<NodeEntry>Implementations§
Source§impl Node
impl Node
Sourcepub fn from_records(collection: &str, records: &BTreeMap<Tid, Cid>) -> Self
pub fn from_records(collection: &str, records: &BTreeMap<Tid, Cid>) -> Self
Build an MST from a key → record CID map. The collection name is used
to form the full record keys (<collection>/<rkey>).
The resulting tree shape is a pure function of the key set — independent
of insertion order — because each key’s level (and thus its position in
the tree) is trailing_zero_bits(sha256(key)).
Sourcepub fn from_keyed_records(records: &BTreeMap<String, Cid>) -> Self
pub fn from_keyed_records(records: &BTreeMap<String, Cid>) -> Self
Build an MST from already-formed full record keys ("<collection>/<rkey>")
to record CID.
Unlike Self::from_records (single collection, keyed by Tid), this
accepts keys spanning multiple collections in one tree — the real
atproto shape (one MST per account repo, not per collection; a repo’s
records live at keys like ai.hyprstream.model/<rkey> and
ai.hyprstream.placement.node/<rkey> side by side in the same tree).
A directory walker enumerates a collection’s records by filtering
entries whose key starts with "<collection>/".
Sourcepub fn from_keyed_records_atproto(records: &BTreeMap<String, Cid>) -> Self
pub fn from_keyed_records_atproto(records: &BTreeMap<String, Cid>) -> Self
Build an MST using the public AT Protocol layer function. The native
Self::from_keyed_records constructor remains unchanged for native
artifacts; callers producing public roots should use this constructor.
Sourcepub fn root_cid(&self) -> Cid
pub fn root_cid(&self) -> Cid
The root CID of this MST (CIDv1 dag-cbor over the root node’s bytes).
Sourcepub fn all_blocks(&self) -> Vec<(Cid, NodeData)>
pub fn all_blocks(&self) -> Vec<(Cid, NodeData)>
All node blocks in the tree (including the root), as (cid, NodeData).
Useful for full-repo CAR export.
Sourcepub fn to_node_data_with_blocks_atproto(
&self,
) -> Result<(NodeData, Vec<(Cid, NodeData)>)>
pub fn to_node_data_with_blocks_atproto( &self, ) -> Result<(NodeData, Vec<(Cid, NodeData)>)>
Serialize this tree with public AT Protocol node ordering and CIDs.
Sourcepub fn proof_atproto<K>(&self, collection: &str, rkey: K) -> Option<Proof>where
K: Into<AtprotoRecordKey>,
pub fn proof_atproto<K>(&self, collection: &str, rkey: K) -> Option<Proof>where
K: Into<AtprotoRecordKey>,
Build an inclusion proof whose node CIDs use public AT serialization.
Sourcepub fn proof(&self, collection: &str, rkey: &Tid) -> Option<Proof>
pub fn proof(&self, collection: &str, rkey: &Tid) -> Option<Proof>
Compute the MST path (inclusion proof) for rkey: the chain of
(NodeData, entry_index) pairs from the root down to the entry whose
key matches, plus the sibling-subtree CIDs needed to verify the chain.
Returns None if the rkey is not present.
Trait Implementations§
impl Eq for Node
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more