pub struct TreeParams<const BODY_SIZE: usize = DEFAULT_BODY_SIZE> { /* private fields */ }Expand description
Tree structure for a file of known size.
Pre-computes chunk counts and spans for efficient parallel operations.
The branching factor defaults to BODY_SIZE / 32 (plain mode, 128 branches).
Use with_ref_size for encrypted mode (BODY_SIZE / 64 = 64 branches).
Implementations§
Source§impl<const BODY_SIZE: usize> TreeParams<BODY_SIZE>
impl<const BODY_SIZE: usize> TreeParams<BODY_SIZE>
Sourcepub fn new(size: u64) -> Self
pub fn new(size: u64) -> Self
Create tree parameters for a file of given size (plain mode, REF_SIZE = 32).
Sourcepub fn with_ref_size(size: u64, ref_size: usize) -> Self
pub fn with_ref_size(size: u64, ref_size: usize) -> Self
Create tree parameters with a custom reference size (e.g. 64 for encrypted mode).
Sourcepub const fn depth(&self) -> usize
pub const fn depth(&self) -> usize
Tree depth (1 = single chunk, 2 = one intermediate level, etc.).
Sourcepub const fn data_chunks(&self) -> u64
pub const fn data_chunks(&self) -> u64
Number of data chunks (level 0).
Sourcepub const fn total_chunks(&self) -> u64
pub const fn total_chunks(&self) -> u64
Total chunks across all levels.
Sourcepub fn chunks_at_level(&self, level: usize) -> u64
pub fn chunks_at_level(&self, level: usize) -> u64
Chunks at a specific level.
Sourcepub fn span_at(&self, level: usize, index: u64) -> u64
pub fn span_at(&self, level: usize, index: u64) -> u64
Span for a chunk at given level and index.
Sourcepub const fn chunk_offset(&self, chunk_index: u64) -> u64
pub const fn chunk_offset(&self, chunk_index: u64) -> u64
Byte offset for start of chunk at level 0.
Sourcepub fn chunk_range(&self, chunk_index: u64) -> (u64, u64)
pub fn chunk_range(&self, chunk_index: u64) -> (u64, u64)
Byte range covered by a data chunk.
Sourcepub fn chunks_for_range(&self, offset: u64, len: u64) -> ChunkRange
pub fn chunks_for_range(&self, offset: u64, len: u64) -> ChunkRange
Calculate required data chunks for a byte range.
Trait Implementations§
Source§impl<const BODY_SIZE: usize> Clone for TreeParams<BODY_SIZE>
impl<const BODY_SIZE: usize> Clone for TreeParams<BODY_SIZE>
Source§fn clone(&self) -> TreeParams<BODY_SIZE>
fn clone(&self) -> TreeParams<BODY_SIZE>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<const BODY_SIZE: usize> Copy for TreeParams<BODY_SIZE>
Auto Trait Implementations§
impl<const BODY_SIZE: usize> Freeze for TreeParams<BODY_SIZE>
impl<const BODY_SIZE: usize> RefUnwindSafe for TreeParams<BODY_SIZE>
impl<const BODY_SIZE: usize> Send for TreeParams<BODY_SIZE>
impl<const BODY_SIZE: usize> Sync for TreeParams<BODY_SIZE>
impl<const BODY_SIZE: usize> Unpin for TreeParams<BODY_SIZE>
impl<const BODY_SIZE: usize> UnsafeUnpin for TreeParams<BODY_SIZE>
impl<const BODY_SIZE: usize> UnwindSafe for TreeParams<BODY_SIZE>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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