3 releases

0.1.2 Apr 19, 2022
0.1.1 Feb 15, 2022
0.1.0 Feb 15, 2022

#24 in #header-parser

Download history 170/week @ 2023-12-12 150/week @ 2023-12-19 42/week @ 2023-12-26 295/week @ 2024-01-02 463/week @ 2024-01-09 924/week @ 2024-01-16 444/week @ 2024-01-23 800/week @ 2024-01-30 559/week @ 2024-02-06 1620/week @ 2024-02-13 1768/week @ 2024-02-20 1458/week @ 2024-02-27 1539/week @ 2024-03-05 1619/week @ 2024-03-12 2197/week @ 2024-03-19 2432/week @ 2024-03-26

8,093 downloads per month
Used in 3 crates (via async_http_range_reader)

MIT/Apache

15KB
271 lines

http-content-range

Build Cr   ates.io Documentation

Tiny Rust lib to decode Content-Range response headers.

extern crate http_content_range;

use http_content_range::ContentRange;

fn main() {
    let content_range_str = "bytes 42-69/420";

    match ContentRange::parse(content_range_str) {
        ContentRange::Bytes(r) => {
            println!(
                "First_byte={}, last_byte={}, complete_length={}",
                r.first_byte, r.last_byte, r.complete_length,
            )
        }
        ContentRange::UnboundBytes(r) => {
            println!(
                "First_byte={}, last_byte={}, complete_length is unknown",
                r.first_byte, r.last_byte
            )
        }
        ContentRange::Unsatisfied(r) => {
            println!(
                "Unsatisfied response, complete_length={}, ",
                r.complete_length
            )
        }
        ContentRange::Unknown => {
            println!("Unable to parse")
        }
    };
}

No runtime deps