Skip to main content

FetchRange

Struct FetchRange 

Source
pub struct FetchRange {
    pub start_group: u64,
    pub start_object: u64,
    pub end_group: u64,
    pub end: FetchEnd,
}
Expand description

The range one AnyConnection::fetch asks for.

Four numbers on drafts 14 through 19, a LOCATION_FILTER parameter on draft-20, and one meaning here. The end Group is absolute on both sides of that split — draft-20’s EndGroupDelta is derived from it, not asked for — and the end Object is FetchEnd, which is the whole point of the type.

§Porting a draft-19 call

A caller that wrote end_object as “the last Object plus one” writes FetchEnd::Object with the last Object, and one that wrote 0 for a whole group writes FetchEnd::EntireGroup. Both send exactly the bytes they sent before on drafts 14 through 19, and the same request on draft-20.

Fields§

§start_group: u64

The Group the range starts in.

§start_object: u64

The Object within start_group the range starts at, inclusive.

§end_group: u64

The Group the range ends in, absolute. Must not be below start_group: draft-20 encodes it as an unsigned delta from the start and has no way to say “backwards”.

§end: FetchEnd

Where the range stops inside end_group.

Implementations§

Source§

impl FetchRange

Source

pub fn through_object( start_group: u64, start_object: u64, end_group: u64, end_object: u64, ) -> Self

A range ending at end_object in end_group, inclusive — that Object is fetched.

Source

pub fn through_end_of_group( start_group: u64, start_object: u64, end_group: u64, ) -> Self

A range covering every Object of end_group, however many there are.

Source

pub fn one_object(group: u64, object: u64) -> Self

A range holding exactly one Object.

The shape an off-by-one is loudest in: a draft-19 encoder writing end_object = object rather than object + 1 asks for nothing at all, and one that ports that arithmetic to draft-20 unchanged asks for two.

Source

pub fn inline_end_object(&self) -> Result<u64, AnyConnectionError>

The End Location.Object drafts 14 through 19 carry inline in FETCH.

Their field is “The end Location, plus 1. A Location.Object value of 0 means the entire group is requested.” — draft-19 Section 10.12.1, and drafts 14 through 18 in the same words. So FetchEnd::Object gains one here and FetchEnd::EntireGroup is 0. This is the only place that + 1 lives, which is what keeps it from reaching draft-20.

§Errors

FetchEnd::Object(u64::MAX) has no encoding in that field — the plus one leaves the number space — and is the one range these drafts cannot express that draft-20 can. Refused rather than wrapped to 0, which would silently ask for the whole group.

Source

pub fn location_filter(&self) -> Result<LocationFilter, AnyConnectionError>

The draft-20 LOCATION_FILTER that carries this range.

Draft-20 Section 10.13 deleted Start Location and End Location from FETCH and moved the range into the parameter, whose ranges Section 5.1.2 calls inclusive. So FetchEnd::Object is written as it stands — nothing here adds one — and FetchEnd::EntireGroup becomes the three-field filter, which Section 5.1.2 defines as covering all Objects in the end Group. The end Group travels as EndGroupDelta, “delta encoded from StartGroup”, so it is end_group - start_group.

§Errors

AnyConnectionError when end_group is below start_group: the delta is unsigned and there is no such filter. Drafts 14 through 19 have two absolute fields and would put such a range on the wire, where the publisher answers it with INVALID_RANGE; the difference is where the refusal happens, not whether the fetch is legal.

Trait Implementations§

Source§

impl Clone for FetchRange

Source§

fn clone(&self) -> FetchRange

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 Copy for FetchRange

Source§

impl Debug for FetchRange

Source§

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

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

impl Eq for FetchRange

Source§

impl PartialEq for FetchRange

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FetchRange

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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