Skip to main content

TorrentMeta

Enum TorrentMeta 

Source
pub enum TorrentMeta {
    V1(TorrentMetaV1),
    V2(TorrentMetaV2),
    Hybrid(Box<TorrentMetaV1>, Box<TorrentMetaV2>),
}
Expand description

A parsed torrent file — v1, v2, or hybrid.

Variants§

§

V1(TorrentMetaV1)

BitTorrent v1 (BEP 3).

§

V2(TorrentMetaV2)

BitTorrent v2 (BEP 52).

§

Hybrid(Box<TorrentMetaV1>, Box<TorrentMetaV2>)

Hybrid v1+v2 (BEP 52). Contains both metadata representations. Boxed to avoid inflating the enum size for the common V1/V2 cases.

Implementations§

Source§

impl TorrentMeta

Source

pub fn info_hashes(&self) -> InfoHashes

Get the unified info hashes.

Source

pub fn is_v1(&self) -> bool

Whether this is a v1 torrent.

Source

pub fn is_v2(&self) -> bool

Whether this is a v2 torrent.

Source

pub fn is_hybrid(&self) -> bool

Whether this is a hybrid v1+v2 torrent.

Source

pub fn version(&self) -> TorrentVersion

Get the protocol version enum.

Source

pub fn as_v1(&self) -> Option<&TorrentMetaV1>

Access the v1 metadata, if present (V1 or Hybrid).

Source

pub fn as_v2(&self) -> Option<&TorrentMetaV2>

Access the v2 metadata, if present (V2 or Hybrid).

Source

pub fn best_v1_info_hash(&self) -> Id20

Get the best v1-compatible info hash for session identification.

For v1 and hybrid: returns the v1 SHA-1 info hash. For v2-only: returns the v2 SHA-256 hash truncated to 20 bytes.

Source

pub fn ssl_cert(&self) -> Option<&[u8]>

Get the SSL CA certificate bytes (PEM), if this is an SSL torrent.

Source

pub fn is_ssl(&self) -> bool

Whether this torrent requires SSL peer connections.

Trait Implementations§

Source§

impl Clone for TorrentMeta

Source§

fn clone(&self) -> TorrentMeta

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TorrentMeta

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<TorrentMetaV1> for TorrentMeta

Source§

fn from(meta: TorrentMetaV1) -> Self

Converts to this type from the input type.
Source§

impl From<TorrentMetaV2> for TorrentMeta

Source§

fn from(meta: TorrentMetaV2) -> Self

Converts to this type from the input type.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.