5 unstable releases

new 0.9.1 Mar 18, 2023
0.9.0 Mar 9, 2023
0.8.0 Mar 5, 2023
0.7.1 Feb 21, 2023
0.7.0 Jan 29, 2023

#531 in Parser implementations

Download history 53/week @ 2023-01-26 128/week @ 2023-02-02 122/week @ 2023-02-09 141/week @ 2023-02-16 129/week @ 2023-02-23 198/week @ 2023-03-02 198/week @ 2023-03-09 500/week @ 2023-03-16

1,043 downloads per month
Used in 3 crates (via vfs-tar)

MIT license

22KB
449 lines

tar-parser

Implementation of a tar archive parser written in rust using nom.

let file = std::fs::read("foo.tar")?;
let (_, entries) = tar_parser2::parse_tar(&file[..])?;
for entry in entries {
    println!("{}", entry.header.name);
}

For more robust example of listing TAR contents, see example ls.


lib.rs:

A nom-based parser for TAR files. This parser only accepts byte slice and doesn't deal with IO.

# fn main() -> Result<(), Box<dyn std::error::Error>> {
let file = std::fs::read("foo.tar")?;
# fn parse(file: &[u8]) -> Result<(), Box<dyn std::error::Error + '_>> {
let (_, entries) = tar_parser2::parse_tar(&file[..])?;
for entry in entries {
    println!("{}", entry.header.name);
}
# Ok(())
# }
# parse(&file[..]).unwrap();
# Ok(())
# }

Dependencies

~1MB
~17K SLoC