Struct hls_m3u8::tags::ExtXByteRange [−][src]
pub struct ExtXByteRange(_);
Expand description
Indicates that a MediaSegment
is a sub-range of the resource identified
by its URI
.
Example
Constructing an ExtXByteRange
:
assert_eq!(ExtXByteRange::from(22..55), ExtXByteRange::from(22..=54));
It is also possible to omit the start, in which case it assumes that the
ExtXByteRange
starts at the byte after the end of the previous
ExtXByteRange
or 0 if there is no previous one.
assert_eq!(ExtXByteRange::from(..55), ExtXByteRange::from(..=54));
Implementations
Adds num
to the start
and end
of the range.
Example
let range = ExtXByteRange::from(10..22); let nrange = range.saturating_add(5); assert_eq!(nrange.len(), range.len()); assert_eq!(nrange.start(), range.start().map(|c| c + 5));
Overflow
If the range is saturated it will not overflow and instead stay at it’s current value.
let range = ExtXByteRange::from(5..usize::max_value()); // this would cause the end to overflow let nrange = range.saturating_add(1); // but the range remains unchanged assert_eq!(range, nrange);
Note
The length of the range will remain unchanged,
if the start
is Some
.
Subtracts num
from the start
and end
of the range.
Example
let range = ExtXByteRange::from(10..22); let nrange = range.saturating_sub(5); assert_eq!(nrange.len(), range.len()); assert_eq!(nrange.start(), range.start().map(|c| c - 5));
Underflow
If the range is saturated it will not underflow and instead stay at it’s current value.
let range = ExtXByteRange::from(0..10); // this would cause the start to underflow let nrange = range.saturating_sub(1); // but the range remains unchanged assert_eq!(range, nrange);
Note
The length of the range will remain unchanged,
if the start
is Some
.
Methods from Deref<Target = ByteRange>
Returns the length, which is calculated by subtracting the end
from
the start
. If the start
is None
a 0 is assumed.
Example
let range = ByteRange::from(1..16); assert_eq!(range.len(), 15);
Trait Implementations
Performs the +=
operation. Read more
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Performs the -=
operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for ExtXByteRange
impl Send for ExtXByteRange
impl Sync for ExtXByteRange
impl Unpin for ExtXByteRange
impl UnwindSafe for ExtXByteRange
Blanket Implementations
Mutably borrows from an owned value. Read more