Skip to main content

SubscriptionFilter

Struct SubscriptionFilter 

Source
pub struct SubscriptionFilter {
    pub filter_type: FilterType,
    pub start_location: Option<Location>,
    pub end_group: Option<FilterEnd>,
}
Expand description

A decoded subscription filter.

The fields after the Filter Type are the ones that type promises, which is why they are optional here and why both directions check them against it: an AbsoluteStart filter puts a Start Location on the wire and no End Group, and the two open-ended types put neither.

Fields§

§filter_type: FilterType

Which of the fields below the filter carries, and where the subscription starts when it carries none.

§start_location: Option<Location>

Present on AbsoluteStart and AbsoluteRange.

§end_group: Option<FilterEnd>

Present on AbsoluteRange alone.

Implementations§

Source§

impl SubscriptionFilter

Source

pub fn decode(bytes: &[u8]) -> Result<Self, CodecError>

Decode a filter from a draft-15 or draft-16 parameter value: QUIC variable-length integers, and an End Group written out in full.

Source

pub fn decode_moqt<P: MoqtProfile>(bytes: &[u8]) -> Result<Self, CodecError>

Decode a filter from a draft-17, draft-18 or draft-19 parameter value: MoQT variable-length integers, and an End Group Delta.

Source

pub fn encode(&self, buf: &mut impl BufMut) -> Result<(), CodecError>

Write this filter as a draft-15 or draft-16 parameter value.

Refuses a filter whose fields disagree with its own Filter Type, for the reason the decoder derives presence from that type: a filter with a surplus field is written out and read back short, and one with a missing field is written short and read back out of whatever follows it in the parameter block. Also refuses a value the QUIC integer encoding cannot spell. That encoding stops at 2^62 - 1 and the fields here are 64-bit, so a Start Location group above the limit would otherwise go out as an unrelated number with the length bits folded into it.

Source

pub fn encode_moqt<P: MoqtProfile>( &self, buf: &mut impl BufMut, ) -> Result<(), CodecError>

Write this filter as a draft-17, draft-18 or draft-19 parameter value.

The same field checks, and no range check: the MoQT integer encoding reaches the whole 64-bit range, so every value these fields can hold has a representation.

Source

pub fn parameter(&self) -> Result<KeyValuePair, CodecError>

This filter as the parameter a draft-15 or draft-16 message carries it in.

The reason to have it: from draft-15 a client asking for a range hands its endpoint a parameter list, and the filter inside it is a run of bytes the caller has to assemble. Assembled by hand it is assembled wrong — the fields present depend on the Filter Type, and a frame short by the ones it promised is one the peer reads off the end of.

Source

pub fn parameter_moqt<P: MoqtProfile>(&self) -> Result<KeyValuePair, CodecError>

This filter as the parameter a draft-17, draft-18 or draft-19 message carries it in.

Source

pub fn from_parameters( parameters: &[KeyValuePair], ) -> Option<Result<Self, CodecError>>

The filter carried by a message’s parameter list, if it carries one.

None when no filter parameter is present, which every draft from 15 on defines as an unfiltered subscription rather than as an omission.

Source

pub fn from_parameters_moqt<P: MoqtProfile>( parameters: &[KeyValuePair], ) -> Option<Result<Self, CodecError>>

The same, reading the MoQT integer encoding of drafts 17 and later.

Source

pub fn last_group(&self) -> Result<Option<u64>, CodecError>

The last Group ID that passes this filter, or None when the filter is open ended.

Errors when the sum leaves the number space, which is a rule drafts 18 and 19 state and draft-17, which introduced the delta, does not. The caller decides whether its draft answers that with a close; every draft needs the addition itself, because a subscription bounded by a delta is bounded by nothing a comparison can use until the delta is resolved.

Trait Implementations§

Source§

impl Clone for SubscriptionFilter

Source§

fn clone(&self) -> SubscriptionFilter

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 SubscriptionFilter

Source§

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

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

impl Eq for SubscriptionFilter

Source§

impl PartialEq for SubscriptionFilter

Source§

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

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.

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.