Skip to main content

PartialTree

Struct PartialTree 

Source
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

Source

pub fn new( declared_root: ContentHash, leaves: Vec<PartialTreeLeaf>, ) -> PartialTree

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.

Source

pub fn from_leaves_verified( declared_root: ContentHash, leaves: Vec<PartialTreeLeaf>, ) -> Result<PartialTree, TreeError>

Assemble and verify that the leaves reconstruct declared_root.

Source

pub fn project( tree: &Tree, redacted: &HashSet<ContentHash>, ) -> Result<PartialTree, 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.

Source

pub fn declared_root(&self) -> ContentHash

Source

pub fn leaves(&self) -> &[PartialTreeLeaf]

Source

pub fn redacted_count(&self) -> usize

Source

pub fn has_redactions(&self) -> bool

Source

pub fn reconstruct_root(&self) -> ContentHash

Reconstruct the Merkle root from the (visible + redacted) leaves.

Source

pub fn verify(&self) -> Result<(), TreeError>

Verify the reconstructed root equals the declared root.

Source

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.

Source

pub fn into_tree(self) -> Result<Tree, TreeError>

Losslessly convert a fully-visible partial tree back to a V4 Tree. Errors if any leaf is redacted (the name/target are unknown) or the reconstructed root does not match the declared root.

Trait Implementations§

Source§

impl Clone for PartialTree

Source§

fn clone(&self) -> PartialTree

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PartialTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for PartialTree

Source§

impl PartialEq for PartialTree

Source§

fn eq(&self, other: &PartialTree) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PartialTree

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more