pub struct MantarayNode {
pub obfuscation_key: [u8; 32],
pub self_address: Option<[u8; 32]>,
pub target_address: [u8; 32],
pub metadata: Option<BTreeMap<String, String>>,
pub path: Vec<u8>,
pub forks: BTreeMap<u8, Fork>,
}Expand description
One node of the Mantaray trie. Field names mirror bee-js / bee-go.
obfuscation_key: 32-byte XOR mask used when serializing this node. Freshly-constructed nodes use a zero key.self_address: chunk address of the marshaled node, populated aftercrate::manifest::wire::calculate_self_address/save_recursively.Nonemeans “not computed”.target_address: file reference at this node, orNULL_ADDRESSfor pure directory nodes.path: edge label inherited from the parent fork’s prefix; the root has an empty path.forks: child edges keyed by first prefix byte (ordered by key).metadata: optional key/value annotations carried in the wire format; ordered by key so JSON serialization is deterministic.
Fields§
§obfuscation_key: [u8; 32]32-byte XOR mask used during marshal.
self_address: Option<[u8; 32]>Chunk address of the marshaled node, when known.
target_address: [u8; 32]File reference at this node (32 bytes; NULL_ADDRESS = none).
metadata: Option<BTreeMap<String, String>>Optional metadata annotations.
path: Vec<u8>Edge label inherited from the parent fork.
forks: BTreeMap<u8, Fork>Child edges keyed by first prefix byte.
Implementations§
Source§impl MantarayNode
impl MantarayNode
Sourcepub fn is_null_target(&self) -> bool
pub fn is_null_target(&self) -> bool
True iff this node’s target_address is the null address.
Sourcepub fn determine_type(&self) -> u8
pub fn determine_type(&self) -> u8
Pack the type bitfield used in this node’s outgoing fork record.
Sourcepub fn find_closest<'a>(&'a self, path: &[u8]) -> (&'a MantarayNode, Vec<u8>)
pub fn find_closest<'a>(&'a self, path: &[u8]) -> (&'a MantarayNode, Vec<u8>)
Walk down forks while path matches. Returns the deepest node
reached and the bytes of path matched along the way.
Sourcepub fn find(&self, path: &[u8]) -> Option<&MantarayNode>
pub fn find(&self, path: &[u8]) -> Option<&MantarayNode>
Return the node whose full path equals path, or None.
Sourcepub fn collect(&self) -> Vec<(Vec<u8>, &MantarayNode)>
pub fn collect(&self) -> Vec<(Vec<u8>, &MantarayNode)>
All descendants whose target_address is non-null, with their
full paths. The path is the concatenation of every fork prefix
from the root down to the node.
Sourcepub fn collect_and_map(&self) -> HashMap<String, Reference>
pub fn collect_and_map(&self) -> HashMap<String, Reference>
{full_path: reference} for every leaf with a valid reference.
Mirrors bee-go CollectAndMap.
Sourcepub fn add_fork(
&mut self,
path: &[u8],
target: Option<&Reference>,
metadata: Option<&BTreeMap<String, String>>,
)
pub fn add_fork( &mut self, path: &[u8], target: Option<&Reference>, metadata: Option<&BTreeMap<String, String>>, )
Insert a (path, target, metadata) entry. Long paths are
chunked into chained nodes of up to MAX_PREFIX_LENGTH
bytes each. Metadata is attached to the terminal node only.
Invalidates self_address on every node touched along the
way; call calculate_self_address (or save_recursively)
before marshaling.
Trait Implementations§
Source§impl Clone for MantarayNode
impl Clone for MantarayNode
Source§fn clone(&self) -> MantarayNode
fn clone(&self) -> MantarayNode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MantarayNode
impl Debug for MantarayNode
Source§impl Default for MantarayNode
impl Default for MantarayNode
Source§impl PartialEq for MantarayNode
impl PartialEq for MantarayNode
Source§fn eq(&self, other: &MantarayNode) -> bool
fn eq(&self, other: &MantarayNode) -> bool
self and other values to be equal, and is used by ==.