pub enum ByteRangeSpec {
FromTo(u64, u64),
AllFrom(u64),
Last(u64),
}Expand description
A single entry of a Range header’s byte-range-set, as defined in
RFC7233 §2.1.
Variants§
FromTo(u64, u64)
first-last: an inclusive range from first to last.
AllFrom(u64)
first-: from first to the end of the representation.
Last(u64)
-suffix: the final suffix bytes of the representation.
Implementations§
Source§impl ByteRangeSpec
impl ByteRangeSpec
Sourcepub fn to_satisfiable_range(&self, content_length: u64) -> Option<(u64, u64)>
pub fn to_satisfiable_range(&self, content_length: u64) -> Option<(u64, u64)>
Resolve this spec against a known content_length into an inclusive
(first, last) byte range, following RFC7233 §2.1.
The end is clamped to content_length - 1, a suffix (-n) range is
anchored to the end of the representation (a suffix at least as long as
the representation yields the whole of it), and None is returned when
the range is unsatisfiable — the cue for a 416 Range Not Satisfiable
response. A returned range always satisfies 0 <= first <= last < content_length.
Trait Implementations§
Source§impl Clone for ByteRangeSpec
impl Clone for ByteRangeSpec
Source§fn clone(&self) -> ByteRangeSpec
fn clone(&self) -> ByteRangeSpec
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ByteRangeSpec
Source§impl Debug for ByteRangeSpec
impl Debug for ByteRangeSpec
Source§impl Display for ByteRangeSpec
impl Display for ByteRangeSpec
impl Eq for ByteRangeSpec
Source§impl Hash for ByteRangeSpec
impl Hash for ByteRangeSpec
Source§impl PartialEq for ByteRangeSpec
impl PartialEq for ByteRangeSpec
Source§fn eq(&self, other: &ByteRangeSpec) -> bool
fn eq(&self, other: &ByteRangeSpec) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ByteRangeSpec
Auto Trait Implementations§
impl Freeze for ByteRangeSpec
impl RefUnwindSafe for ByteRangeSpec
impl Send for ByteRangeSpec
impl Sync for ByteRangeSpec
impl Unpin for ByteRangeSpec
impl UnsafeUnpin for ByteRangeSpec
impl UnwindSafe for ByteRangeSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more