Skip to main content

byte_ranges

Function byte_ranges 

Source
pub fn byte_ranges(
    value: &[u8],
    length: u64,
    out: &mut [ByteRange],
) -> Result<RangeOutcome, ParseError>
Expand description

Parses and resolves Range against length with the default limits and no coalescing.

§Errors

As parse. RFC 9110 lets a server ignore a Range it cannot read: treat an error as RangeOutcome::Ignore unless the request should be refused.

§Examples

use parse_net::{byte_ranges, ByteRange, RangeOutcome};

let mut out = [ByteRange { start: 0, end: 0 }; 1];
assert_eq!(byte_ranges(b"bytes=0-0, 2-2", 10, &mut out)?, RangeOutcome::Ignore); // `out` too small