[−][src]Struct torro::torrent::Torrent
The primary representation of a torrent, created from a parsing function like bencode::parse. This representation is used to interact with many parts of torro.
Documentation sourcing
All "BitTorrent Description" headings are taken from
BEP0003 and is subject to
change, like any moving standard. This documentation is based off of version
0e08ddf84d8d3bf101cdf897fc312f2774588c9e
Fields
announce: String
name: String
Advised save name for torrent once leeched, is use by torro by default but may be changed
BitTorrent Description
The `name` key maps to a UTF-8 encoded string which is the suggested name
to save the file (or directory) as. It is purely advisory.
piece_length: usize
File buffer (aka piece) length, commonly a power of 2 (e.g. 2
, 4
,
8
, 16
)
BitTorrent Description
`piece length` maps to the number of bytes in each piece the file is split
into. For the purposes of transfer, files are split into fixed-size pieces
which are all the same length except for possibly the last one which may
be truncated. piece length is almost always a power of two, most commonly
2 18 = 256 K (BitTorrent prior to version 3.2 uses 2 20 = 1 M as default).
pieces: Vec<Vec<u8>>
A vector of binary-encoded SHA hashes corrosponding to each Torrent::piece_length
BitTorrent Description
Please note that torro represents this "(byte)string whose length is a
multiple of 20" as a Vec<Vec<u8>>
with each iteration of top-most vec
containing a Vec<u8>
-coded hash for simplicity
`pieces` maps to a string whose length is a multiple of 20. It is to be
subdivided into strings of length 20, each of which is the SHA1 hash of
the piece at the corresponding index.
file_structure: TorrentFile
The overall file structure of the torrent, see the TorrentFile enum for more infomation
BitTorrent Description
We have merged the two options into a single enum for easier digesting inside of Rust
There is also a key length or a key files, but not both or neither. If
length is present then the download represents a single file, otherwise
it represents a set of files which go in a directory structure.
In the single file case, length maps to the length of the file in bytes.
For the purposes of the other keys, the multi-file case is treated as
only having a single file by concatenating the files in the order they
appear in the files list. The files list is the value files maps to, and
is a list of dictionaries containing the following keys:
length - The length of the file, in bytes.
path - A list of UTF-8 encoded strings corresponding to subdirectory names,
the last of which is the actual file name (a zero length list is an error
case).
In the single file case, the name key is the name of a file, in the
muliple file case, it's the name of a directory.
Implementations
impl Torrent
[src]
pub fn new(torrent_data: Vec<u8>) -> Result<Self, TorroError>
[src]
Creates a new Torrent from given torrent_data
formatted as Vec<u8>
If an error is encountered, it will be a TorrentCreationError wrapped inside of TorroError::TorrentCreationError
pub fn from_file(file: PathBuf) -> Result<Self, TorroError>
[src]
Creates a new Torrent from given .torrent
file path
Trait Implementations
impl Clone for Torrent
[src]
impl Debug for Torrent
[src]
impl PartialEq<Torrent> for Torrent
[src]
impl StructuralPartialEq for Torrent
[src]
Auto Trait Implementations
impl RefUnwindSafe for Torrent
impl Send for Torrent
impl Sync for Torrent
impl Unpin for Torrent
impl UnwindSafe for Torrent
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,