pub struct RandomXorb { /* private fields */ }Expand description
A XORB that generates its chunk data on-the-fly from random seeds.
This allows testing with massive files without actually storing the data in memory.
Each chunk is defined by a seed and size, and the data is generated deterministically
using SmallRng when needed.
Implementations§
Source§impl RandomXorb
impl RandomXorb
Sourcepub fn new(chunk_specs: &[(u64, u32)]) -> Self
pub fn new(chunk_specs: &[(u64, u32)]) -> Self
Creates a new RandomXorb from a list of (seed, size) pairs.
The chunk data is generated deterministically from each seed, and chunk hashes are computed and cached.
Sourcepub fn from_seed(seed: u64, num_chunks: u32, chunk_size: u32) -> Self
pub fn from_seed(seed: u64, num_chunks: u32, chunk_size: u32) -> Self
Creates a new RandomXorb from a seed, number of chunks, and chunk size.
Each chunk gets a unique sub-seed derived from the main seed.
Sourcepub fn num_chunks(&self) -> u32
pub fn num_chunks(&self) -> u32
Returns the number of chunks in this XORB.
Sourcepub fn xorb_hash(&self) -> MerkleHash
pub fn xorb_hash(&self) -> MerkleHash
Returns the hash of the XORB.
Sourcepub fn chunk_hash(&self, idx: u32) -> Option<MerkleHash>
pub fn chunk_hash(&self, idx: u32) -> Option<MerkleHash>
Returns the hash of a specific chunk.
Sourcepub fn chunk_size(&self, idx: u32) -> Option<u32>
pub fn chunk_size(&self, idx: u32) -> Option<u32>
Returns the uncompressed size of a specific chunk.
Sourcepub fn total_uncompressed_size(&self) -> u64
pub fn total_uncompressed_size(&self) -> u64
Returns the total uncompressed size of all chunks.
Sourcepub fn chunk_range_size(&self, start: u32, end: u32) -> u64
pub fn chunk_range_size(&self, start: u32, end: u32) -> u64
Returns the total uncompressed size for a range of chunks [start, end).
Sourcepub fn chunk_hash_sizes(&self, start: u32, end: u32) -> Vec<(MerkleHash, u64)>
pub fn chunk_hash_sizes(&self, start: u32, end: u32) -> Vec<(MerkleHash, u64)>
Returns (hash, size) pairs for a range of chunks [start, end). This is useful for computing file hashes.
Sourcepub fn chunk_hashes_range(&self, start: u32, end: u32) -> Vec<MerkleHash> ⓘ
pub fn chunk_hashes_range(&self, start: u32, end: u32) -> Vec<MerkleHash> ⓘ
Returns the chunk hashes for a range of chunks [start, end).
Sourcepub fn get_chunk_data(&self, idx: u32) -> Option<Bytes>
pub fn get_chunk_data(&self, idx: u32) -> Option<Bytes>
Generates and returns the raw data for a specific chunk.
Sourcepub fn get_chunk_range_data(&self, start: u32, end: u32) -> Option<Bytes>
pub fn get_chunk_range_data(&self, start: u32, end: u32) -> Option<Bytes>
Generates and returns the raw data for a range of chunks [start, end).
Sourcepub fn get_xorb_object(&self) -> XorbObject
pub fn get_xorb_object(&self) -> XorbObject
Returns the XorbObject header/footer for this XORB.
Uses no compression (CompressionScheme::None) for all chunks.
Sourcepub fn serialized_length(&self) -> u64
pub fn serialized_length(&self) -> u64
Returns the total serialized length of the XORB (chunks + footer).
Sourcepub fn get_serialized_range(&self, start: u64, end: u64) -> Bytes
pub fn get_serialized_range(&self, start: u64, end: u64) -> Bytes
Returns the serialized bytes for a range within the XORB.
This generates the bytes on-the-fly, including chunk headers and data. The range is in terms of the serialized byte positions.
Sourcepub fn get_full_serialized(&self) -> Bytes
pub fn get_full_serialized(&self) -> Bytes
Returns the full serialized XORB.
Note: This materializes the entire XORB, which may be large.
Prefer get_serialized_range for partial access.
Trait Implementations§
Source§impl Clone for RandomXorb
impl Clone for RandomXorb
Source§fn clone(&self) -> RandomXorb
fn clone(&self) -> RandomXorb
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RandomXorb
impl RefUnwindSafe for RandomXorb
impl Send for RandomXorb
impl Sync for RandomXorb
impl Unpin for RandomXorb
impl UnsafeUnpin for RandomXorb
impl UnwindSafe for RandomXorb
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> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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>
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