pub enum ByteRange {
FromTo(u64),
FromToAll(u64, u64),
Last(u64),
}
Variants§
Implementations§
Source§impl ByteRange
impl ByteRange
Sourcepub fn parse(header: &str) -> Vec<Self>
pub fn parse(header: &str) -> Vec<Self>
Parses Range HTTP header string as per RFC 2733,but bytes
only.
With invalid input, return empty vector
§Examples
use range_header::ByteRange;
assert_eq!(
ByteRange::parse("bytes=10-100"),
vec![ByteRange::FromToAll(10, 100)]
);
assert_eq!(
ByteRange::parse("bytes=10-"),
vec![ByteRange::FromTo(10)]
);
assert_eq!(
ByteRange::parse("bytes=-100"),
vec![ByteRange::Last(100)]
);
assert_eq!(
ByteRange::parse("invalid input"),
vec![]
);
Trait Implementations§
impl Eq for ByteRange
impl StructuralPartialEq for ByteRange
Auto Trait Implementations§
impl Freeze for ByteRange
impl RefUnwindSafe for ByteRange
impl Send for ByteRange
impl Sync for ByteRange
impl Unpin for ByteRange
impl UnwindSafe for ByteRange
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