[][src]Struct cratetorrent::metainfo::Metainfo

pub struct Metainfo {
    pub name: String,
    pub info_hash: Sha1Hash,
    pub pieces: Vec<u8>,
    pub piece_len: u32,
    pub files: Vec<FileInfo>,
    pub trackers: Vec<Url>,
}

The parsed and validated torrent metainfo file, containing necessary arguments for starting a torrent.

Fields

name: String

The name of the torrent, which is usually used to form the download path.

info_hash: Sha1Hash

This hash is used to identify a torrent with trackers and peers.

pieces: Vec<u8>

The concatenation of the 20 byte SHA-1 hash of each piece in torrent. This is used to verify the data sent to us by peers.

piece_len: u32

The nominal lengths of a piece, that is, the length of all but potentially the last piece, which may be smaller.

files: Vec<FileInfo>

The paths and lenths of the files in torrent.

trackers: Vec<Url>

The trackers that we can announce to. The tier information is not currently present in this field as cratetorrent doesn't use it. In the future it may be added.

Implementations

impl Metainfo[src]

pub fn from_bytes(buf: &[u8]) -> Result<Self, MetainfoError>[src]

Parses from a byte buffer a new Metainfo instance, or aborts with an error.

If the encoding itself is correct, the constructor may still fail if the metadata is not semantically correct (e.g. if the length of the pieces field is not a multiple of 20, or no valid files are encoded, etc).

pub fn is_archive(&self) -> bool[src]

Returns true if the download is for an archive.

pub fn download_len(&self) -> u64[src]

Returns the total download size in bytes.

Note that this is an O(n) operation for archive downloads, where n is the number of files, so the return value should ideally be cached.

pub fn piece_count(&self) -> usize[src]

Returns the number of pieces in this torrent.

Trait Implementations

impl Clone for Metainfo[src]

impl Debug for Metainfo[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.