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: u64The Group the range starts in.
start_object: u64The Object within start_group the range starts at, inclusive.
end_group: u64The 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: FetchEndWhere the range stops inside end_group.
Implementations§
Source§impl FetchRange
impl FetchRange
Sourcepub fn through_object(
start_group: u64,
start_object: u64,
end_group: u64,
end_object: u64,
) -> Self
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.
Sourcepub fn through_end_of_group(
start_group: u64,
start_object: u64,
end_group: u64,
) -> Self
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.
Sourcepub fn one_object(group: u64, object: u64) -> Self
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.
Sourcepub fn inline_end_object(&self) -> Result<u64, AnyConnectionError>
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.
Sourcepub fn location_filter(&self) -> Result<LocationFilter, AnyConnectionError>
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
impl Clone for FetchRange
Source§fn clone(&self) -> FetchRange
fn clone(&self) -> FetchRange
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more