pub struct LocationFilter {
fields: Vec<u64>,
}Expand description
A draft-20 LOCATION_FILTER (Parameter Type 0x21), Section 5.1.2.
LOCATION_FILTER Parameter {
Parameter Type (vi64) = 0x21,
Length (vi64),
[StartGroup (vi64),]
[StartObject (vi64),]
[EndGroupDelta (vi64),]
[EndObject (vi64),]
}§The shape is the field count
Draft-19’s filter opened with a Filter Type enum — Next Group Start,
Largest Object, AbsoluteStart, AbsoluteRange — and draft-20 deleted it. What
selects the shape now is how many vi64 fields the value holds, and the
draft phrases that as “Length (in bytes) determines how many optional vi64
fields are present”. That is not implementable as written: MoQT varints are
one to nine bytes and Section 1.4.1 permits non-minimal encodings, so a
Length of 2 fits two one-byte fields as readily as one two-byte field.
This module always emits minimal varints, so the byte length and the field
count agree for everything it produces, and the codec’s decoder counts
fields rather than bytes. The two agree on every value built here; they part
only on a non-minimally-encoded value from a peer, which is the decoder’s
problem and not this one’s.
Each constructor names one row of the Section 5.1.2 table, so a caller cannot build a shape the draft does not define, and cannot build a three-field filter by leaving a field out of a four-field one.
§Migrating a draft-19 filter
Filter Type 0x1 (Next Group Start) becomes LocationFilter::relative
with 0. Filter Type 0x2 (Largest Object) becomes
LocationFilter::next_object. Filter Types 0x3 and 0x4 become
LocationFilter::absolute_start and LocationFilter::range. The
one-field relative form has no draft-19 analogue outside the deleted
Relative Joining Fetch.
Fields§
§fields: Vec<u64>Implementations§
Source§impl LocationFilter
impl LocationFilter
Sourcepub fn none() -> Self
pub fn none() -> Self
No filter at all: Length = 0, no fields.
Section 5.1.2 gives this one job beyond meaning “unfiltered”: in a REQUEST_UPDATE it removes a filter already in force. It is the one shape whose meaning depends on the message carrying it.
Sourcepub fn relative(start_group: u64) -> Self
pub fn relative(start_group: u64) -> Self
One field: a start relative to the live edge.
Section 5.1.2: Start is {Largest Object.Group + 1 - StartGroup, 0}, so
0 is the next group, 1 the current group, and N is N - 1 groups
before the current one. Clamped at both ends of the number space by the
publisher rather than here, because resolving it needs Largest Object.
Open-ended: there is no end.
Sourcepub fn absolute_start(start_group: u64, start_object: u64) -> Self
pub fn absolute_start(start_group: u64, start_object: u64) -> Self
Two fields: an absolute start, open-ended.
{0, 0} is not the beginning of the track — Section 5.1.2 makes it
the Next Object, {Largest Object.Group, Largest Object.Object + 1}, or
{0,0} when nothing has been delivered. LocationFilter::next_object
is that case spelled out; this constructor accepts it too, and means the
same thing.
Sourcepub fn next_object() -> Self
pub fn next_object() -> Self
The two-field {0, 0} special case: start at the Next Object.
Section 5.1.3 names this filter as half of the recipe for exactly-once delivery on a subscription with a fill: a Next Object subscription filter paired with an open-ended fill range, which the publisher ends at Largest Object.
Sourcepub fn range(
start_group: u64,
start_object: u64,
end_group_delta: u64,
) -> Result<Self, FillError>
pub fn range( start_group: u64, start_object: u64, end_group_delta: u64, ) -> Result<Self, FillError>
Three fields: an absolute start and an end group, covering all objects in the end group.
Section 5.1.2: “EndGroupDelta is delta encoded from StartGroup, but both
the start and end groups are absolute, not relative to Largest Object.”
So the end group is start_group + end_group_delta, and a delta of 0
ends in the group it started in.
§Errors
FillError::EndGroupOverflow when the sum leaves the number space,
which Section 5.1.2 makes a PROTOCOL_VIOLATION at the receiver.
Sourcepub fn range_to(
start_group: u64,
start_object: u64,
end_group_delta: u64,
end_object: u64,
) -> Result<Self, FillError>
pub fn range_to( start_group: u64, start_object: u64, end_group_delta: u64, end_object: u64, ) -> Result<Self, FillError>
Four fields: a fully specified inclusive range,
{start_group, start_object} through
{start_group + end_group_delta, end_object}.
end_object is the Object ID of the last object the range covers. It is
not that Object ID plus one, and an end_object of 0 means object 0
rather than the whole group — both draft-19 conventions were deleted
without a note in the change log, and this is the constructor where a
ported + 1 does its damage.
§Errors
Sourcepub fn encode_value(&self) -> Vec<u8> ⓘ
pub fn encode_value(&self) -> Vec<u8> ⓘ
The encoded value, without the parameter type or the length ahead of it.
Sourcepub fn parameter(&self) -> Result<KeyValuePair, FillError>
pub fn parameter(&self) -> Result<KeyValuePair, FillError>
This filter as the Message Parameter that carries it.
§Errors
FillError::NotRoundTrippable if the codec’s own
decode_location_filter does not read back the fields that went in.
Trait Implementations§
Source§impl Clone for LocationFilter
impl Clone for LocationFilter
Source§fn clone(&self) -> LocationFilter
fn clone(&self) -> LocationFilter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more