pub struct SnapshotBundle {
pub format_version: u32,
pub tree: Tree,
pub nodes: Vec<SnapshotBundleNode>,
}Expand description
Self-contained transport bundle for one tree and its reachable node bytes.
The bundle is intended for import/export between stores, processes, and
language bindings. nodes should contain exactly the node CIDs reachable
from tree.root, sorted by raw CID bytes for deterministic transport.
Fields§
§format_version: u32Bundle schema version. Currently always 1.
tree: TreeTree handle the imported store will be able to read.
nodes: Vec<SnapshotBundleNode>Reachable serialized nodes for the tree.
Implementations§
Source§impl SnapshotBundle
impl SnapshotBundle
Sourcepub fn new(tree: Tree, nodes: Vec<SnapshotBundleNode>) -> Self
pub fn new(tree: Tree, nodes: Vec<SnapshotBundleNode>) -> Self
Create a versioned snapshot bundle from a tree and reachable node bytes.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of serialized nodes in the bundle.
Sourcepub fn byte_count(&self) -> usize
pub fn byte_count(&self) -> usize
Total serialized node bytes in the bundle.
Sourcepub fn digest(&self) -> Result<Cid, Error>
pub fn digest(&self) -> Result<Cid, Error>
Return the SHA-256 digest of this bundle’s canonical byte encoding.
The digest is stable for semantically equivalent bundles: node entries are canonicalized by CID before encoding, so caller-side ordering does not affect the result.
Sourcepub fn summary(&self) -> Result<SnapshotBundleSummary, Error>
pub fn summary(&self) -> Result<SnapshotBundleSummary, Error>
Return validated metadata for this bundle without importing it.
The summary canonicalizes node order, deduplicates identical repeated nodes, and verifies each node byte payload against its CID.
Sourcepub fn verify(&self) -> Result<SnapshotBundleVerification, Error>
pub fn verify(&self) -> Result<SnapshotBundleVerification, Error>
Verify that this bundle is complete and contains no unreachable nodes.
This check is read-only: it validates version, canonicalizes nodes, verifies every node byte payload by CID, decodes reachable nodes from the supplied bytes, and compares the reachable CID set with the bundled CID set.
Sourcepub fn validate_format_version(&self) -> Result<(), Error>
pub fn validate_format_version(&self) -> Result<(), Error>
Validate that the bundle version is supported by this crate.
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>, Error>
pub fn to_bytes(&self) -> Result<Vec<u8>, Error>
Serialize this bundle as deterministic, versioned bytes.
The encoded form canonicalizes node order by CID bytes and deduplicates repeated identical nodes. It rejects unsupported bundle versions, malformed CIDs, and node bytes whose content hash does not match the supplied CID.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Decode a deterministic, versioned snapshot bundle byte payload.
Trait Implementations§
Source§impl Clone for SnapshotBundle
impl Clone for SnapshotBundle
Source§fn clone(&self) -> SnapshotBundle
fn clone(&self) -> SnapshotBundle
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 SnapshotBundle
impl Debug for SnapshotBundle
Source§impl PartialEq for SnapshotBundle
impl PartialEq for SnapshotBundle
impl StructuralPartialEq for SnapshotBundle
Auto Trait Implementations§
impl Freeze for SnapshotBundle
impl RefUnwindSafe for SnapshotBundle
impl Send for SnapshotBundle
impl Sync for SnapshotBundle
impl Unpin for SnapshotBundle
impl UnsafeUnpin for SnapshotBundle
impl UnwindSafe for SnapshotBundle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more