Skip to main content

XorbBlock

Struct XorbBlock 

Source
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: usize

Index 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

Source

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.

Source

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§

Source§

impl PartialEq for XorbBlock

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for XorbBlock

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> DropFlavorWrapper<T> for T

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more