pub struct RangeFilter {
pub parameter_type: u64,
pub set_id: u8,
pub property_type: Option<u64>,
pub ranges: Vec<FilterRange>,
}Expand description
A decoded Range Filter parameter value.
Fields§
§parameter_type: u64Which of the five filters this is.
set_id: u8The set this filter belongs to. “All filter parameters with the same SetID value are combined using logical ‘AND’ operations, then all the resulting sets are combined using logical ‘OR’ operations.” So the SetID is not decoration: two filters under one SetID both have to pass, and two filters under different SetIDs each pass on their own.
property_type: Option<u64>The property this filter is about, on the two property filters.
None on SUBGROUP_FILTER, OBJECTID_FILTER and PRIORITY_FILTER, whose
subject is fixed by the parameter type.
ranges: Vec<FilterRange>The ranges, with every delta resolved to an absolute value.
Implementations§
Source§impl RangeFilter
impl RangeFilter
Sourcepub fn decode_moqt<P: MoqtProfile>(
parameter_type: u64,
bytes: &[u8],
) -> Result<Self, RangeFilterError>
pub fn decode_moqt<P: MoqtProfile>( parameter_type: u64, bytes: &[u8], ) -> Result<Self, RangeFilterError>
Read a Range Filter from the bytes of its parameter value.
bytes is the value after the Key-Value-Pair’s Length has been consumed,
which is what a decoded parameter holds — the Length in Section 5.1.3’s
figure is that same prefix and not a second one inside the value.
An empty value decodes to a filter with no ranges rather than an error:
“In REQUEST_UPDATE, Length can be 0 to remove a filter parameter or
non-zero to replace that entire filter parameter including all sets and
Property Types.” The three-field filters can express that in zero bytes
only if the SetID is also absent, so an empty value is taken as the
removal and anything shorter than its own prefix is not.
Sourcepub fn decode_moqt_structure<P: MoqtProfile>(
parameter_type: u64,
bytes: &[u8],
) -> Result<Self, RangeFilterError>
pub fn decode_moqt_structure<P: MoqtProfile>( parameter_type: u64, bytes: &[u8], ) -> Result<Self, RangeFilterError>
Read a Range Filter without holding it to the two rules about its own
contents that check_its_own_types states.
The bytes still have to be a Range Filter and still have to parse: a
truncated value, a missing SetID and a delta that overflows are all
refused here exactly as they are by decode_moqt.
What is not refused is a filter that decoded cleanly and then names a
Publisher Priority above 255 or an odd Property Type.
§When to reach for this instead
A decoder must refuse those two, because they are answered with REQUEST_ERROR and passing them on would let an application act on a range the peer is not allowed to have asked for. A renderer must not: it is describing a message that has already been decoded, and a filter that broke a content rule is exactly the one whose fields a reader most needs to see. Refusing there degrades the rendering to opaque bytes and hides the offending value inside them.
So the split is by what the caller does with the answer, not by how
much checking it wants: decode with decode_moqt,
render with this and then call
check_its_own_types to say what is wrong
alongside the fields rather than instead of them.
Sourcepub fn check_its_own_types(&self) -> Result<(), RangeFilterError>
pub fn check_its_own_types(&self) -> Result<(), RangeFilterError>
The two rules a Range Filter can break once it has decoded cleanly.
Both are answered with the same REQUEST_ERROR as the delta rule, so
decode_moqt applies them for you and a filter
that reaches an application through it has already been held to
everything Section 5.1.3 and Sections 10.2.12 through 10.2.14 state
about its own contents. What is left for the session to decide is the
ceiling and the repeats, which need more than one parameter to see.
It is public so that a caller which decoded with
decode_moqt_structure can still ask the
question — and, having the filter in hand, report the answer beside the
fields rather than in place of them.
Sourcepub fn encode_moqt<P: MoqtProfile>(
&self,
buf: &mut impl BufMut,
) -> Result<(), RangeFilterError>
pub fn encode_moqt<P: MoqtProfile>( &self, buf: &mut impl BufMut, ) -> Result<(), RangeFilterError>
Write this filter as a parameter value.
Refuses what the decoder refuses, and one thing more: a range whose End is below its Start, and an unbounded range anywhere but last. Both encode perfectly well and neither reads back as what was written — a backwards End wraps its delta into a nine-byte integer that resolves to an unrelated value, and an unbounded range in the middle silently pairs its successor’s Start as its own End.
Sourcepub fn passes(&self, value: u64) -> bool
pub fn passes(&self, value: u64) -> bool
Whether value passes this filter.
A filter with no ranges passes nothing, which is what a filter that lists no acceptable values says. The removal form of a REQUEST_UPDATE is the same shape on the wire and is not the same statement, so a caller acting on an update reads the removal from the parameter’s zero Length before it asks anything to pass.
Sourcepub fn key(&self) -> RangeFilterKey
pub fn key(&self) -> RangeFilterKey
This filter’s key for the rule about repeats.
Trait Implementations§
Source§impl Clone for RangeFilter
impl Clone for RangeFilter
Source§fn clone(&self) -> RangeFilter
fn clone(&self) -> RangeFilter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more