pub struct PartialTree { /* private fields */ }Expand description
A redaction projection of a V4 Tree: visible entries keep their
preimage + salt; redacted entries are reduced to their opaque 32-byte leaf
hash. A PartialTree reconstructs the SAME Merkle root as the full tree, so
a state that commits to the full tree still verifies against the projection.
This is deliberately NOT a Tree (a Tree requires a resolved name+target
for every entry); a viewer holding redacted leaves cannot author over them.
Implementations§
Source§impl PartialTree
impl PartialTree
Sourcepub fn new(declared_root: ContentHash, leaves: Vec<PartialTreeLeaf>) -> Self
pub fn new(declared_root: ContentHash, leaves: Vec<PartialTreeLeaf>) -> Self
Assemble a partial tree from its declared root and leaves. Callers that
need the root checked should use Self::verify or
Self::from_leaves_verified.
Sourcepub fn from_leaves_verified(
declared_root: ContentHash,
leaves: Vec<PartialTreeLeaf>,
) -> Result<Self, TreeError>
pub fn from_leaves_verified( declared_root: ContentHash, leaves: Vec<PartialTreeLeaf>, ) -> Result<Self, TreeError>
Assemble and verify that the leaves reconstruct declared_root.
Sourcepub fn project(
tree: &Tree,
redacted: &HashSet<ContentHash>,
) -> Result<Self, TreeError>
pub fn project( tree: &Tree, redacted: &HashSet<ContentHash>, ) -> Result<Self, TreeError>
Project a full V4 tree, redacting every entry whose leaf hash is in
redacted. Entries not in redacted stay visible. Errors on a V3 tree
(nothing to salt) or a broken salt invariant.
pub fn declared_root(&self) -> ContentHash
pub fn leaves(&self) -> &[PartialTreeLeaf]
pub fn redacted_count(&self) -> usize
pub fn has_redactions(&self) -> bool
Sourcepub fn reconstruct_root(&self) -> ContentHash
pub fn reconstruct_root(&self) -> ContentHash
Reconstruct the Merkle root from the (visible + redacted) leaves.
Sourcepub fn verify(&self) -> Result<(), TreeError>
pub fn verify(&self) -> Result<(), TreeError>
Verify the reconstructed root equals the declared root.
Sourcepub fn visible_tree(&self) -> Result<Tree, TreeError>
pub fn visible_tree(&self) -> Result<Tree, TreeError>
Build a V4 Tree from ONLY the visible entries of this projection,
dropping the withheld (redacted) leaves entirely. Unlike
PartialTree::into_tree, this never errors on redacted leaves — it
omits them. The result’s hash therefore does NOT equal the declared
root (it has fewer entries); it is the “visible set” view for status
comparison, where the withheld entries are unknown to this client by
construction and so must not be reported as local deletions.