Skip to main content

LocationFilter

Struct LocationFilter 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

FillError::EndGroupOverflow, as LocationFilter::range.

Source

pub fn fields(&self) -> &[u64]

The vi64 fields, in wire order.

Source

pub fn encode_value(&self) -> Vec<u8>

The encoded value, without the parameter type or the length ahead of it.

Source

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

Source§

fn clone(&self) -> LocationFilter

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 LocationFilter

Source§

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

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

impl Eq for LocationFilter

Source§

impl PartialEq for LocationFilter

Source§

fn eq(&self, other: &LocationFilter) -> 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 LocationFilter

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