pub struct BlockIndex {
pub version: String,
pub algorithm: HashAlgorithm,
pub root: DocumentId,
pub blocks: Vec<BlockHashEntry>,
}Expand description
Index of content blocks with their hashes.
This structure is stored at content/block-index.json and enables:
- Merkle proof generation for individual blocks
- Efficient verification of specific content sections
- Selective disclosure without revealing full content
Fields§
§version: StringVersion of the block index format.
algorithm: HashAlgorithmHash algorithm used for all hashes.
root: DocumentIdMerkle root hash of all blocks.
blocks: Vec<BlockHashEntry>Individual block entries with their hashes.
Implementations§
Source§impl BlockIndex
impl BlockIndex
Sourcepub fn from_content(content: &Content, algorithm: HashAlgorithm) -> Result<Self>
pub fn from_content(content: &Content, algorithm: HashAlgorithm) -> Result<Self>
Create a block index from document content.
This computes hashes for each block and builds a Merkle tree to derive the root hash.
§Errors
Returns an error if the content has no blocks.
Sourcepub fn merkle_root(&self) -> &DocumentId
pub fn merkle_root(&self) -> &DocumentId
Get the Merkle root hash.
Sourcepub fn block_count(&self) -> usize
pub fn block_count(&self) -> usize
Get the number of blocks.
Sourcepub fn find_block(&self, id: &str) -> Option<&BlockHashEntry>
pub fn find_block(&self, id: &str) -> Option<&BlockHashEntry>
Find a block entry by ID.
Sourcepub fn get_block(&self, index: usize) -> Option<&BlockHashEntry>
pub fn get_block(&self, index: usize) -> Option<&BlockHashEntry>
Find a block entry by index.
Sourcepub fn hashes(&self) -> Vec<&DocumentId>
pub fn hashes(&self) -> Vec<&DocumentId>
Get all block hashes in order.
Trait Implementations§
Source§impl Clone for BlockIndex
impl Clone for BlockIndex
Source§fn clone(&self) -> BlockIndex
fn clone(&self) -> BlockIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BlockIndex
impl Debug for BlockIndex
Source§impl<'de> Deserialize<'de> for BlockIndex
impl<'de> Deserialize<'de> for BlockIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for BlockIndex
impl PartialEq for BlockIndex
Source§impl Serialize for BlockIndex
impl Serialize for BlockIndex
impl Eq for BlockIndex
impl StructuralPartialEq for BlockIndex
Auto Trait Implementations§
impl Freeze for BlockIndex
impl RefUnwindSafe for BlockIndex
impl Send for BlockIndex
impl Sync for BlockIndex
impl Unpin for BlockIndex
impl UnsafeUnpin for BlockIndex
impl UnwindSafe for BlockIndex
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.