Skip to main content

GetAvailabilityParams

Struct GetAvailabilityParams 

Source
#[non_exhaustive]
pub struct GetAvailabilityParams { pub items: Vec<AvailabilityQuery>, pub redirect_depth: Option<u64>, }
Expand description

Params for dig.getAvailability.

§Construction

Like FetchRangeParams, this type is #[non_exhaustive]: build it with new plus the with_* setters rather than a struct literal, so a future additive field is a PATCH for every consumer instead of a semver cascade.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§items: Vec<AvailabilityQuery>

The items to check. Capped at 512 per batch (past-cap items are dropped).

§redirect_depth: Option<u64>

The hop budget already consumed by this ask. Absent means zero — read it through hops_consumed, never directly.

§What it means for an availability ask

An availability answer is not only this node’s holdings: on a miss it may name the holders it located, in AvailabilityAnswer::providers — the same enrichment a RedirectInfo carries. A responder that cannot answer from what it holds MAY ask its own peers, so one caller’s question can walk several hops, and each hop is a node spending someone else’s bandwidth. This field is what bounds that walk.

It is the SAME budget, counted the SAME way, as RedirectInfo::redirect_depth and as the redirect_depth that GetContentParams and FetchRangeParams already echo: the number of hops ALREADY CONSUMED when this ask arrives, counting UP from zero — never a remaining allowance counting down. A responder that asks onward sends hops_consumed() + 1 (saturating at the type maximum), and MUST NOT ask onward when that would reach the budget it advertises as RedirectInfo::max_redirects.

Absent reads as a fresh, unhopped ask, so a client written before this field existed is served unchanged.

Implementations§

Source§

impl GetAvailabilityParams

Source

pub fn new(items: Vec<AvailabilityQuery>) -> Self

An availability batch for items, asked at hop zero.

Source

pub fn with_redirect_depth(self, redirect_depth: u64) -> Self

Echo the hop budget already consumed — from a -32008 redirect, or from the ask this one is being made on behalf of. See redirect_depth.

Source

pub fn hops_consumed(&self) -> u64

The hops already consumed by this ask.

The single home for the “absent means zero” rule. A responder that reached for redirect_depth.is_some() instead would read every pre-0.8 client’s ask as budget-free and forward it without bound — the amplification the budget exists to stop.

Trait Implementations§

Source§

impl Clone for GetAvailabilityParams

Source§

fn clone(&self) -> GetAvailabilityParams

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GetAvailabilityParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for GetAvailabilityParams

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for GetAvailabilityParams

Source§

impl PartialEq for GetAvailabilityParams

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for GetAvailabilityParams

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for GetAvailabilityParams

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.