pub struct InnerFile {
pub name: String,
pub length: u64,
/* private fields */
}Expand description
A file inside a RAR archive.
Represents a logical file that may span multiple physical chunks across multiple archive volumes. Provides methods for reading file content with automatic decompression and decryption.
§Example
// Get file from parsed archive
let files = package.parse(opts).await?;
let file = &files[0];
// Check properties
println!("{}: {} bytes", file.name, file.length);
// Read content
let content = file.read_to_end().await?;§Caching
Decompressed content is cached internally. Subsequent calls to
read_decompressed return the cached data without re-decompressing.
Fields§
§name: StringFull path of the file inside the archive.
length: u64Uncompressed size in bytes.
Implementations§
Source§impl InnerFile
impl InnerFile
pub fn new( name: String, chunks: Vec<RarFileChunk>, method: u8, unpacked_size: u64, rar_version: RarVersion, ) -> Self
Sourcepub fn new_with_solid(
name: String,
chunks: Vec<RarFileChunk>,
method: u8,
unpacked_size: u64,
rar_version: RarVersion,
is_solid: bool,
) -> Self
pub fn new_with_solid( name: String, chunks: Vec<RarFileChunk>, method: u8, unpacked_size: u64, rar_version: RarVersion, is_solid: bool, ) -> Self
Create an InnerFile with solid archive flag.
Sourcepub fn new_with_solid_dict(
name: String,
chunks: Vec<RarFileChunk>,
method: u8,
dict_size_log: u8,
unpacked_size: u64,
rar_version: RarVersion,
is_solid: bool,
) -> Self
pub fn new_with_solid_dict( name: String, chunks: Vec<RarFileChunk>, method: u8, dict_size_log: u8, unpacked_size: u64, rar_version: RarVersion, is_solid: bool, ) -> Self
Create an InnerFile with solid archive flag and dictionary size.
Sourcepub fn new_encrypted(
name: String,
chunks: Vec<RarFileChunk>,
method: u8,
unpacked_size: u64,
rar_version: RarVersion,
encryption: Option<EncryptionInfo>,
password: Option<String>,
) -> Self
pub fn new_encrypted( name: String, chunks: Vec<RarFileChunk>, method: u8, unpacked_size: u64, rar_version: RarVersion, encryption: Option<EncryptionInfo>, password: Option<String>, ) -> Self
Create an InnerFile with encryption info.
Sourcepub fn new_encrypted_with_solid(
name: String,
chunks: Vec<RarFileChunk>,
method: u8,
unpacked_size: u64,
rar_version: RarVersion,
encryption: Option<EncryptionInfo>,
password: Option<String>,
is_solid: bool,
) -> Self
pub fn new_encrypted_with_solid( name: String, chunks: Vec<RarFileChunk>, method: u8, unpacked_size: u64, rar_version: RarVersion, encryption: Option<EncryptionInfo>, password: Option<String>, is_solid: bool, ) -> Self
Create an InnerFile with encryption info and solid flag.
Sourcepub fn new_encrypted_with_solid_dict(
name: String,
chunks: Vec<RarFileChunk>,
method: u8,
dict_size_log: u8,
unpacked_size: u64,
rar_version: RarVersion,
encryption: Option<EncryptionInfo>,
password: Option<String>,
is_solid: bool,
) -> Self
pub fn new_encrypted_with_solid_dict( name: String, chunks: Vec<RarFileChunk>, method: u8, dict_size_log: u8, unpacked_size: u64, rar_version: RarVersion, encryption: Option<EncryptionInfo>, password: Option<String>, is_solid: bool, ) -> Self
Create an InnerFile with encryption info, solid flag, and dictionary size.
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Check if this file is encrypted.
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
Returns true if this file is compressed.
Sourcepub fn find_chunk_index(&self, offset: u64) -> Option<usize>
pub fn find_chunk_index(&self, offset: u64) -> Option<usize>
Find which chunk contains the given offset using binary search. O(log n) complexity for fast seeking.
Sourcepub fn get_chunk_entry(&self, index: usize) -> Option<&ChunkMapEntry>
pub fn get_chunk_entry(&self, index: usize) -> Option<&ChunkMapEntry>
Get chunk entry by index.
Sourcepub fn get_chunk(&self, index: usize) -> Option<&RarFileChunk>
pub fn get_chunk(&self, index: usize) -> Option<&RarFileChunk>
Get the underlying chunk by index.
Sourcepub fn chunk_count(&self) -> usize
pub fn chunk_count(&self) -> usize
Number of chunks in this file.
Sourcepub async fn read_to_end(&self) -> Result<Vec<u8>>
pub async fn read_to_end(&self) -> Result<Vec<u8>>
Read the entire file.
Sourcepub async fn read_decompressed(&self) -> Result<Arc<Vec<u8>>>
pub async fn read_decompressed(&self) -> Result<Arc<Vec<u8>>>
Read decompressed data (with caching).
Sourcepub async fn read_range(&self, interval: ReadInterval) -> Result<Vec<u8>>
pub async fn read_range(&self, interval: ReadInterval) -> Result<Vec<u8>>
Read a range of bytes from the file. Optimized for sequential reads within chunks.
Sourcepub fn stream_range(&self, start: u64, end: u64) -> InnerFileStream<'_>
pub fn stream_range(&self, start: u64, end: u64) -> InnerFileStream<'_>
Create a streaming reader for a byte range. Yields chunks incrementally for backpressure-aware streaming.
Source§impl InnerFile
impl InnerFile
Sourcepub fn get_stream_chunks(&self, start: u64, end: u64) -> Vec<StreamChunkInfo>
pub fn get_stream_chunks(&self, start: u64, end: u64) -> Vec<StreamChunkInfo>
Get detailed chunk info for streaming prioritization. Useful for telling the torrent engine which pieces to prioritize.