55 releases (31 stable)
| 10.0.1 | Oct 7, 2025 |
|---|---|
| 9.2.0 | Jul 15, 2025 |
| 9.0.0 | Mar 6, 2025 |
| 8.0.0 | Feb 20, 2025 |
| 0.4.1 | Dec 13, 2022 |
#124 in Filesystem
81,355 downloads per month
Used in 50 crates
(19 directly)
525KB
12K
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.
use webc::{Container, Version};
let bytes: &[u8] = b"\0webc...";
let container = Container::from_bytes_and_version(bytes.into(), Version::V3)?;
println!("{:?}", container.manifest());
println!("Atoms:");
for (name, atom) in container.atoms() {
let length = atom.len();
println!("{name}: {length} bytes");
}
for (name, volume) in container.volumes() {
let root_items = volume.read_dir("/").expect("The root directory always exists");
println!("{name}: {} items", root_items.len());
}
In general, errors that occur during lazy operations won't be accessible to the user.
Version-Specific Fallbacks
If more flexibility is required, consider using [crate::detect()] and
instantiating a compatible parser directly.
use webc::{
Container,
Version,
};
use webc::v1::{ParseOptions, WebC};
use webc::v3::read::OwnedReader;
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::V3) => {
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}"),
}
Feature Flags
Dependencies
~9–29MB
~405K SLoC