pub struct XorbBlock {
pub xorb_hash: MerkleHash,
pub chunk_ranges: Vec<ChunkRange>,
pub xorb_block_index: usize,
pub references: Vec<XorbReference>,
pub uncompressed_size_if_known: Option<usize>,
pub data: OnceCell<Arc<XorbBlockData>>,
}Expand description
A downloadable xorb block identified by hash and chunk ranges, with cached data.
A block may contain multiple disjoint chunk ranges from the same xorb (V2 multi-range).
Multiple file terms may reference the same block. Downloaded data is cached in data
so that the first term to request it triggers the download, and subsequent terms
reuse the cached result.
Fields§
§xorb_hash: MerkleHash§chunk_ranges: Vec<ChunkRange>The chunk ranges fetched for this block. For V1 this is a single range; for V2 multi-range fetches this may contain multiple disjoint ranges.
xorb_block_index: usizeIndex into the parent TermBlockRetrievalURLs for URL lookup.
references: Vec<XorbReference>All file-term references covered by this block, sorted by chunk range start.
Populated during retrieve_file_term_block and used to compute uncompressed_size_if_known.
uncompressed_size_if_known: Option<usize>Expected total decompressed size across all chunk ranges, if it can be determined from the references. Passed to clients as a debug assertion hint.
data: OnceCell<Arc<XorbBlockData>>Implementations§
Source§impl XorbBlock
impl XorbBlock
Sourcepub async fn retrieve_data(
self: Arc<Self>,
client: Arc<dyn Client>,
url_info: Arc<TermBlockRetrievalURLs>,
progress_updater: Option<Arc<ItemProgressUpdater>>,
chunk_cache: Option<Arc<dyn ChunkCache>>,
) -> Result<Arc<XorbBlockData>>
pub async fn retrieve_data( self: Arc<Self>, client: Arc<dyn Client>, url_info: Arc<TermBlockRetrievalURLs>, progress_updater: Option<Arc<ItemProgressUpdater>>, chunk_cache: Option<Arc<dyn ChunkCache>>, ) -> Result<Arc<XorbBlockData>>
Retrieve the xorb block data from the client, caching it for subsequent calls.
Uses single-flight: the first caller acquires a CAS download permit and downloads the data; concurrent callers wait on the same result without acquiring permits or duplicating work. If the download fails, the cell remains empty and a later caller can retry.
Sourcepub fn determine_size_if_possible(
xorb_ranges: &[ChunkRange],
terms: &[XorbReference],
) -> Option<usize>
pub fn determine_size_if_possible( xorb_ranges: &[ChunkRange], terms: &[XorbReference], ) -> Option<usize>
Determines the total uncompressed size of the xorb block from the reference terms, if possible.
Uses a forward-chaining DP: starting from the first chunk range’s start, we track which chunk positions are “reachable” (i.e., fully covered by a contiguous chain of terms) along with the accumulated uncompressed size.
For multi-range blocks with disjoint chunk ranges (e.g. [0,3) and [5,8)),
the gaps between ranges are inserted as zero-cost bridges. This lets the DP
traverse the full set of ranges in a single pass — a gap [3,5) contributes
no data but connects the end of one range to the start of the next.
Returns Some(total_size) if every range is fully covered, None otherwise.
The terms slice must be sorted by term_chunks.start.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for XorbBlock
impl !RefUnwindSafe for XorbBlock
impl Send for XorbBlock
impl Sync for XorbBlock
impl Unpin for XorbBlock
impl UnsafeUnpin for XorbBlock
impl UnwindSafe for XorbBlock
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> 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