34 releases (stable)

5.8.1 Nov 22, 2023
5.7.0 Oct 25, 2023
5.2.2 Jul 27, 2023
5.0.0-rc.7 Mar 28, 2023
0.4.1 Dec 13, 2022

#126 in Filesystem

Download history 15434/week @ 2023-10-31 15129/week @ 2023-11-07 18557/week @ 2023-11-14 12403/week @ 2023-11-21 11678/week @ 2023-11-28 13489/week @ 2023-12-05 9728/week @ 2023-12-12 9920/week @ 2023-12-19 3857/week @ 2023-12-26 14363/week @ 2024-01-02 11025/week @ 2024-01-09 15465/week @ 2024-01-16 11307/week @ 2024-01-23 12680/week @ 2024-01-30 10681/week @ 2024-02-06 7433/week @ 2024-02-13

43,368 downloads per month
Used in 29 crates (14 directly)

MIT and maybe LGPL-2.0-or-later

445KB
9K SLoC

A library for reading and writing WEBC files.

The Container provides an abstraction over the various WEBC versions this crate can handle. As such, it tries to cater to the lowest common denominator and favors portability over performance or power.

In general, errors that occur during lazy operations won't be accessible to the user.

If more flexibility is required, consider using [crate::detect()] and instantiating a compatible parser directly.

use webc::{
    Container,
    Version,
    v2::read::OwnedReader,
    v1::{ParseOptions, WebC},
};
let bytes: &[u8] = b"...";

match webc::detect(bytes) {
    Ok(Version::V1) => {
        let options = ParseOptions::default();
        let webc = WebC::parse(bytes, &options).unwrap();
        if let Some(signature) = webc.signature {
            println!("Package signature: {:?}", signature);
        }
    }
    Ok(Version::V2) => {
        let webc = OwnedReader::parse(bytes).unwrap();
        let index = webc.index();
        let signature = &index.signature;
        if !signature.is_none() {
            println!("Package signature: {signature:?}");
        }
    }
    Ok(other) => todo!("Unsupported version, {other}"),
    Err(e) => todo!("An error occurred: {e}"),
}

Dependencies

~5–21MB
~309K SLoC