pub struct Node {
pub left: Option<Cid>,
pub entries: Vec<Entry>,
}
Expand description
MST node data schema
Fields§
§left: Option<Cid>
link to sub-tree Node on a lower level and with all keys sorting before keys at this node
entries: Vec<Entry>
ordered list of TreeEntry objects
atproto MSTs have a fanout of 4, so there can be max 4 entries.
Implementations§
Source§impl Node
impl Node
Sourcepub fn could_be(bytes: impl AsRef<[u8]>) -> bool
pub fn could_be(bytes: impl AsRef<[u8]>) -> bool
test if a block could possibly be a node
we can’t eagerly decode records except where we’re sure they cannot be an mst node (and even then we can only attempt) because you can’t know with certainty what a block is supposed to be without actually walking the tree.
so if a block could be a node, any record converter must postpone processing. if it turns out it happens to be a very node-looking record, well, sorry, it just has to only be processed later when that’s known.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if a node has any entries
An empty repository with no records is represented as a single MST node with an empty array of entries. This is the only situation in which a tree may contain an empty leaf node which does not either contain keys (“entries”) or point to a sub-tree containing entries.
TODO: to me this is slightly unclear with respect to l
(ask someone).
…is that what “The top of the tree must not be a an empty node which
only points to a sub-tree.” is referring to?