pub struct ContentRange { /* private fields */ }
Expand description
Content-Range, described in RFC7233
§ABNF
Content-Range = byte-content-range
/ other-content-range
byte-content-range = bytes-unit SP
( byte-range-resp / unsatisfied-range )
byte-range-resp = byte-range "/" ( complete-length / "*" )
byte-range = first-byte-pos "-" last-byte-pos
unsatisfied-range = "*/" complete-length
complete-length = 1*DIGIT
other-content-range = other-range-unit SP other-range-resp
other-range-resp = *CHAR
§Example
use headers::ContentRange;
// 100 bytes (included byte 199), with a full length of 3,400
let cr = ContentRange::bytes(100..200, 3400).unwrap();
Implementations§
Source§impl ContentRange
impl ContentRange
Sourcepub fn bytes(
range: impl RangeBounds<u64>,
complete_length: impl Into<Option<u64>>,
) -> Result<ContentRange, InvalidContentRange>
pub fn bytes( range: impl RangeBounds<u64>, complete_length: impl Into<Option<u64>>, ) -> Result<ContentRange, InvalidContentRange>
Construct a new Content-Range: bytes ..
header.
Sourcepub fn unsatisfied_bytes(complete_length: u64) -> ContentRange
pub fn unsatisfied_bytes(complete_length: u64) -> ContentRange
Create a new ContentRange
stating the range could not be satisfied.
The passed argument is the complete length of the entity.
Sourcepub fn bytes_range(&self) -> Option<(u64, u64)>
pub fn bytes_range(&self) -> Option<(u64, u64)>
Get the byte range if satisified.
Note that these byte ranges are inclusive on both ends.
Trait Implementations§
Source§impl Clone for ContentRange
impl Clone for ContentRange
Source§fn clone(&self) -> ContentRange
fn clone(&self) -> ContentRange
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ContentRange
impl Debug for ContentRange
Source§impl Header for ContentRange
impl Header for ContentRange
Source§fn name() -> &'static HeaderName
fn name() -> &'static HeaderName
The name of this header.
Source§fn decode<'i, I>(values: &mut I) -> Result<ContentRange, Error>where
I: Iterator<Item = &'i HeaderValue>,
fn decode<'i, I>(values: &mut I) -> Result<ContentRange, Error>where
I: Iterator<Item = &'i HeaderValue>,
Decode this type from an iterator of
HeaderValue
s.Source§impl PartialEq for ContentRange
impl PartialEq for ContentRange
impl StructuralPartialEq for ContentRange
Auto Trait Implementations§
impl Freeze for ContentRange
impl RefUnwindSafe for ContentRange
impl Send for ContentRange
impl Sync for ContentRange
impl Unpin for ContentRange
impl UnwindSafe for ContentRange
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<H> HeaderExt for Hwhere
H: Header + Sealed,
impl<H> HeaderExt for Hwhere
H: Header + Sealed,
Source§fn encode_to_value(&self) -> HeaderValue
fn encode_to_value(&self) -> HeaderValue
Encode this
Header
to HeaderValue
.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