pub enum ContentRange {
Bytes(ContentRangeBytes),
UnboundBytes(ContentRangeUnbound),
Unsatisfied(ContentRangeUnsatisfied),
Unknown,
}Expand description
HTTP Content-Range response header representation.
Variants§
Bytes(ContentRangeBytes)
Regular bytes range response with status 206
UnboundBytes(ContentRangeUnbound)
Regular bytes range response with status 206
Unsatisfied(ContentRangeUnsatisfied)
Server response with status 416
Unknown
Header cannot be parsed. This includes non-standard response with status 206
Implementations§
source§impl ContentRange
impl ContentRange
sourcepub fn parse(header: &str) -> ContentRange
pub fn parse(header: &str) -> ContentRange
Parses Content-Range HTTP header string as per RFC 7233.
header is the HTTP Content-Range header (e.g. bytes 0-9/30).
This parser is a bit more lenient than the official RFC, it allows spaces and tabs between everything. See https://httpwg.org/specs/rfc7233.html#rfc.section.4.2
use http_content_range::{ContentRange, ContentRangeBytes, ContentRangeUnbound, ContentRangeUnsatisfied};
assert_eq!(ContentRange::parse("bytes 42-69/420"),
ContentRange::Bytes(ContentRangeBytes{first_byte: 42, last_byte: 69, complete_length: 420}));
// complete_length is unknown
assert_eq!(ContentRange::parse("bytes 42-69/*"),
ContentRange::UnboundBytes(ContentRangeUnbound{first_byte: 42, last_byte: 69}));
// response is unsatisfied
assert_eq!(ContentRange::parse("bytes */420"),
ContentRange::Unsatisfied(ContentRangeUnsatisfied{complete_length: 420}));sourcepub fn parse_bytes(header: &[u8]) -> ContentRange
pub fn parse_bytes(header: &[u8]) -> ContentRange
Same as parse but parses directly from the byte array
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 PartialEq for ContentRange
impl PartialEq for ContentRange
impl Copy for ContentRange
impl Eq 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)