Skip to main content

InnerFile

Struct InnerFile 

Source
pub struct InnerFile {
    pub name: String,
    pub length: u64,
    /* private fields */
}
Available on crate feature async only.
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: String

Full path of the file inside the archive.

§length: u64

Uncompressed size in bytes.

Implementations§

Source§

impl InnerFile

Source

pub fn new( name: String, chunks: Vec<RarFileChunk>, method: u8, unpacked_size: u64, rar_version: RarVersion, ) -> Self

Create a new uncompressed or compressed inner file with default dictionary size.

Source

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.

Source

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.

Source

pub fn new_encrypted( name: String, chunks: Vec<RarFileChunk>, method: u8, unpacked_size: u64, rar_version: RarVersion, encryption: Option<EncryptionInfo>, password: Option<String>, ) -> Self

Available on crate feature crypto only.

Create an InnerFile with encryption info.

Source

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

Available on crate feature crypto only.

Create an InnerFile with encryption info and solid flag.

Source

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

Available on crate feature crypto only.

Create an InnerFile with encryption info, solid flag, and dictionary size.

Source

pub fn is_encrypted(&self) -> bool

Available on crate feature crypto only.

Check if this file is encrypted.

Source

pub fn is_solid(&self) -> bool

Check if this file is part of a solid archive.

Source

pub fn is_compressed(&self) -> bool

Returns true if this file is compressed.

Source

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.

Source

pub fn get_chunk_entry(&self, index: usize) -> Option<&ChunkMapEntry>

Get chunk entry by index.

Source

pub fn get_chunk(&self, index: usize) -> Option<&RarFileChunk>

Get the underlying chunk by index.

Source

pub fn chunk_count(&self) -> usize

Number of chunks in this file.

Source

pub async fn read_to_end(&self) -> Result<Vec<u8>>

Read the entire file.

Source

pub async fn read_to_end_shared(&self) -> Result<Arc<Vec<u8>>>

Read the entire file, returning a shared reference for compressed data.

For compressed files this avoids a copy compared to [read_to_end] — the cached decompressed buffer is returned directly. For stored files this behaves identically to read_to_end.

Source

pub async fn read_decompressed(&self) -> Result<Arc<Vec<u8>>>

Read decompressed data (with caching).

Source

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.

Source

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

pub fn get_chunk_ranges(&self, start: u64, end: u64) -> Vec<(usize, u64, u64)>

Get chunk boundaries for a range (useful for prioritizing torrent pieces). Returns (chunk_index, chunk_start_offset, chunk_end_offset) for each chunk.

Source

pub fn translate_offset(&self, offset: u64) -> Option<(usize, u64)>

Translate a logical offset to (volume_index, volume_offset). Useful for mapping seek positions to torrent pieces.

Source§

impl InnerFile

Source

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.

Trait Implementations§

Source§

impl Debug for InnerFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.