Expand description
Sans-IO tar archive parser.
This module provides a sans-IO state machine parser for tar archives.
It operates on &[u8] slices directly (no Read trait bound), making
it suitable for:
- Async I/O (tokio, async-std)
- Custom buffering strategies
- Zero-copy parsing in memory-mapped archives
- Embedding in other parsers
In addition to the parser itself, this module contains the configuration
and error types it uses: Limits for security limits and ParseError
for error reporting.
§Design
The parser is a state machine that processes bytes and emits ParseEvents.
The caller is responsible for:
- Providing input data via
Parser::parse - Handling events (headers, content markers, end-of-archive)
- Managing the buffer and reading more data when needed
§Example
use tar_core::parse::{Parser, ParseEvent, Limits};
let mut parser = Parser::new(Limits::default());
// Simulated tar data (in practice, read from file/network)
let data = [0u8; 1024]; // Two zero blocks = end of archive
match parser.parse(&data) {
Ok(ParseEvent::End { consumed }) => {
println!("End of archive after {} bytes", consumed);
}
Ok(event) => {
println!("Got event {:?}", event);
}
Err(e) => {
eprintln!("Parse error: {}", e);
}
}Structs§
- Limits
- Configurable security limits for tar archive parsing.
- Parsed
Entry - A fully-resolved tar entry with all extensions applied.
- Parser
- Sans-IO tar archive parser.
Enums§
- Parse
Error - Errors that can occur during tar archive parsing.
- Parse
Event - Events emitted by the sans-IO parser.
Type Aliases§
- Result
- Result type for parsing operations.