pub enum RarError {
Show 13 variants
InvalidSignature,
InvalidHeader,
InvalidHeaderType(u8),
DecompressionNotSupported(u8),
EncryptedNotSupported,
PasswordRequired,
DecryptionFailed(String),
BufferTooSmall {
needed: usize,
have: usize,
},
InvalidOffset {
offset: u64,
length: u64,
},
Io(Error),
NoFilesFound,
Rar5NotFullySupported,
EncryptedHeaders,
}Expand description
Error type for RAR operations.
This enum covers all possible errors that can occur when parsing,
decompressing, or decrypting RAR archives. It implements std::error::Error
for integration with the Rust error handling ecosystem.
§Example
use rar_stream::RarError;
fn handle_error(err: RarError) {
match err {
RarError::InvalidSignature => {
// File doesn't start with RAR magic bytes
}
RarError::PasswordRequired => {
// Need to provide password in ParseOptions
}
RarError::Io(io_err) => {
// Underlying I/O error (file not found, permission denied, etc.)
}
_ => {}
}
}Variants§
InvalidSignature
The file does not have a valid RAR signature.
RAR files must start with either:
- RAR4:
Rar!\x1a\x07\x00(7 bytes) - RAR5:
Rar!\x1a\x07\x01\x00(8 bytes)
InvalidHeader
A header in the archive is malformed or corrupt.
This usually indicates file corruption or an incomplete download.
InvalidHeaderType(u8)
An unknown or unsupported header type was encountered.
The u8 value is the header type byte. Standard types are:
0x72(114): Marker header0x73(115): Archive header0x74(116): File header0x7B(123): End of archive
DecompressionNotSupported(u8)
The compression method is not supported.
The u8 value is the method byte:
0x30: Store (no compression) - always supported0x31-0x35: LZSS variants - supported0x36+: Future methods - may not be supported
EncryptedNotSupported
The archive is encrypted but the crypto feature is not enabled.
Enable the crypto feature in Cargo.toml:
rar-stream = { version = "4", features = ["async", "crypto"] }PasswordRequired
The archive is encrypted but no password was provided.
Provide a password in ParseOptions:
let opts = ParseOptions {
password: Some("secret".to_string()),
..Default::default()
};DecryptionFailed(String)
Decryption failed (wrong password or corrupt data).
The String contains additional context about the failure.
Common causes:
- Incorrect password
- Corrupt encrypted data
- Truncated archive
BufferTooSmall
The provided buffer is too small.
This occurs when reading into a fixed-size buffer that cannot hold the required data.
InvalidOffset
An invalid file offset was requested.
This occurs when seeking beyond the end of a file or archive.
Io(Error)
An I/O error occurred.
Wraps std::io::Error for file system operations.
NoFilesFound
No files were found in the archive.
The archive may be empty, or all files may have been filtered out.
Rar5NotFullySupported
RAR5 format detected but a specific feature is not supported.
This is a legacy error that should rarely occur with current versions.
EncryptedHeaders
The archive has encrypted headers and requires a password to list files.
RAR5 archives created with rar -hp encrypt both file data and headers.
Without the correct password, even file names cannot be read.