RawMetainfo

Struct RawMetainfo 

Source
pub struct RawMetainfo<'a> { /* private fields */ }
Expand description

Borrowed, syntax-level view of a BitTorrent metainfo dictionary.

Implementations§

Source§

impl<'a> RawMetainfo<'a>

Source

pub fn from_bytes(original: &'a [u8]) -> Result<Self>

Parses a top-level metainfo dictionary while preserving original bytes.

§Errors

Returns a syntax/resource error from bencode parsing, or a metainfo error when the root is not a dictionary or info is missing, duplicated, or not a dictionary.

Source

pub fn from_bytes_with_options( original: &'a [u8], options: ParseOptions, ) -> Result<Self>

Parses a top-level metainfo dictionary using caller-provided limits.

§Errors

Returns a syntax/resource error from bencode parsing, or a metainfo error when the root is not a dictionary or info is invalid.

Source

pub fn canonicality(&self) -> Canonicality

Reports whether the original source uses canonical bencode.

Source

pub const fn original_bytes(&self) -> &'a [u8] ⓘ

Returns the complete original metainfo bytes.

Source

pub fn info_bytes(&self) -> &'a [u8] ⓘ

Returns the exact original encoded info bytes.

Source

pub fn info_span(&self) -> Span

Returns the exact source span of the encoded info dictionary.

Source

pub fn info_value(&self) -> &Value<'a>

Returns the parsed info dictionary value.

Source

pub fn announce(&self) -> Option<&Value<'a>>

Returns the first announce field, when present.

Source

pub fn announce_list(&self) -> Option<&Value<'a>>

Returns the first announce-list field, when present.

Source

pub fn url_list(&self) -> Option<&Value<'a>>

Returns the first url-list field, when present.

Source

pub fn nodes(&self) -> Option<&Value<'a>>

Returns the first nodes field, when present.

Source

pub fn comment(&self) -> Option<&Value<'a>>

Returns the first comment field, when present.

Source

pub fn created_by(&self) -> Option<&Value<'a>>

Returns the first created by field, when present.

Source

pub fn creation_date(&self) -> Option<&Value<'a>>

Returns the first creation date field, when present.

Source

pub fn unknown_fields(&self) -> Vec<(ByteString<'a>, &Value<'a>)>

Returns top-level entries whose keys are not recognized by this view.

Source

pub fn info_hash_sha1(&self) -> [u8; 20]

Computes SHA-1 over the exact original info bytes.

Source

pub fn info_hash_sha256(&self) -> [u8; 32]

Computes SHA-256 over the exact original info bytes.

Trait Implementations§

Source§

impl<'a> Debug for RawMetainfo<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RawMetainfo<'a>

§

impl<'a> RefUnwindSafe for RawMetainfo<'a>

§

impl<'a> Send for RawMetainfo<'a>

§

impl<'a> Sync for RawMetainfo<'a>

§

impl<'a> Unpin for RawMetainfo<'a>

§

impl<'a> UnwindSafe for RawMetainfo<'a>

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.