pub struct File {
pub path: PathBuf,
pub length: u64,
pub offset: u64,
pub pieces_root: Option<[u8; 32]>,
pub attr: Option<String>,
}Expand description
A file within a torrent.
For single-file torrents, there is one file with the torrent name. For multi-file torrents, paths are relative to the torrent’s root directory.
Fields§
§path: PathBufPath to the file (relative to torrent root).
length: u64Size of the file in bytes.
offset: u64Byte offset within the torrent’s piece data.
For v1 torrents, this is the contiguous byte offset. For v2 torrents, each file is piece-aligned, so this represents the byte offset accounting for padding between files.
pieces_root: Option<[u8; 32]>The merkle root hash for this file (v2 torrents only).
This is a 32-byte SHA256 hash that is the root of the merkle tree built from 16 KiB block hashes. Empty files have no pieces_root.
attr: Option<String>File attributes (v2 torrents only).
Common attributes:
- “p”: Padding file (used for v1 compatibility in hybrid torrents)
- “x”: Executable file
- “h”: Hidden file
Implementations§
Source§impl File
impl File
Sourcepub fn is_padding(&self) -> bool
pub fn is_padding(&self) -> bool
Returns true if this is a padding file.
Padding files are used in hybrid torrents to align v2 files to piece boundaries for v1 compatibility.
Sourcepub fn is_executable(&self) -> bool
pub fn is_executable(&self) -> bool
Returns true if this is marked as executable.
Returns true if this is marked as hidden.