pub struct InfoDictV2 {
pub name: String,
pub piece_length: u64,
pub meta_version: u64,
pub file_tree: FileTreeNode,
pub ssl_cert: Option<Vec<u8>>,
}Expand description
v2 info dictionary (BEP 52).
Key difference from v1: files are represented as a nested tree, and piece_length
is a global value (power of 2, ≥ 16 KiB). Files are aligned to piece boundaries —
each file starts on a new piece, and the last piece of each file may be shorter.
Fields§
§name: StringSuggested name for the torrent.
piece_length: u64Global piece length in bytes. Must be a power of 2, ≥ 16384.
meta_version: u64Meta version — always 2 for v2 torrents.
file_tree: FileTreeNodeThe nested file tree.
ssl_cert: Option<Vec<u8>>BEP 35 / SSL torrent: PEM-encoded X.509 CA certificate. When present, all peer connections must use TLS with certs chaining to this CA.
Implementations§
Source§impl InfoDictV2
impl InfoDictV2
Sourcepub fn files(&self) -> Vec<V2FileInfo>
pub fn files(&self) -> Vec<V2FileInfo>
Get all files as a flat list.
Sourcepub fn total_length(&self) -> u64
pub fn total_length(&self) -> u64
Total size of all files in bytes.
Sourcepub fn num_pieces(&self) -> u32
pub fn num_pieces(&self) -> u32
Total number of pieces across all files.
In v2, each file starts on a new piece boundary, so the total is the
sum of per-file piece counts (not simply ceil(total_length / piece_length)).
Sourcepub fn file_piece_ranges(&self) -> Vec<(V2FileInfo, u32, u32)>
pub fn file_piece_ranges(&self) -> Vec<(V2FileInfo, u32, u32)>
Per-file piece ranges: (file_info, global_piece_offset, file_piece_count).
Each file starts at a new global piece offset due to v2 alignment.
Trait Implementations§
Source§impl Clone for InfoDictV2
impl Clone for InfoDictV2
Source§fn clone(&self) -> InfoDictV2
fn clone(&self) -> InfoDictV2
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more