pub struct RawMetainfo<'a> { /* private fields */ }Expand description
Borrowed, syntax-level view of a BitTorrent metainfo dictionary.
Implementations§
Source§impl<'a> RawMetainfo<'a>
impl<'a> RawMetainfo<'a>
Sourcepub fn from_bytes(original: &'a [u8]) -> Result<Self>
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.
Sourcepub fn from_bytes_with_options(
original: &'a [u8],
options: ParseOptions,
) -> Result<Self>
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.
Sourcepub fn canonicality(&self) -> Canonicality
pub fn canonicality(&self) -> Canonicality
Reports whether the original source uses canonical bencode.
Sourcepub const fn original_bytes(&self) -> &'a [u8] ⓘ
pub const fn original_bytes(&self) -> &'a [u8] ⓘ
Returns the complete original metainfo bytes.
Sourcepub fn info_bytes(&self) -> &'a [u8] ⓘ
pub fn info_bytes(&self) -> &'a [u8] ⓘ
Returns the exact original encoded info bytes.
Sourcepub fn info_value(&self) -> &Value<'a>
pub fn info_value(&self) -> &Value<'a>
Returns the parsed info dictionary value.
Sourcepub fn announce_list(&self) -> Option<&Value<'a>>
pub fn announce_list(&self) -> Option<&Value<'a>>
Returns the first announce-list field, when present.
Sourcepub fn created_by(&self) -> Option<&Value<'a>>
pub fn created_by(&self) -> Option<&Value<'a>>
Returns the first created by field, when present.
Sourcepub fn creation_date(&self) -> Option<&Value<'a>>
pub fn creation_date(&self) -> Option<&Value<'a>>
Returns the first creation date field, when present.
Sourcepub fn unknown_fields(&self) -> Vec<(ByteString<'a>, &Value<'a>)>
pub fn unknown_fields(&self) -> Vec<(ByteString<'a>, &Value<'a>)>
Returns top-level entries whose keys are not recognized by this view.
Sourcepub fn info_hash_sha1(&self) -> [u8; 20]
pub fn info_hash_sha1(&self) -> [u8; 20]
Computes SHA-1 over the exact original info bytes.
Sourcepub fn info_hash_sha256(&self) -> [u8; 32]
pub fn info_hash_sha256(&self) -> [u8; 32]
Computes SHA-256 over the exact original info bytes.