MetainfoEditor

Struct MetainfoEditor 

Source
pub struct MetainfoEditor { /* private fields */ }
Expand description

Owned metainfo editor preserving untouched known and unknown fields.

Implementations§

Source§

impl MetainfoEditor

Source

pub fn from_metainfo(metainfo: &Metainfo) -> Result<Self>

Starts from a parsed validated metainfo object.

§Errors

Returns an error if parsing or owned top-level conversion fails.

Source

pub fn from_info(info: OwnedValue) -> Result<Self>

Starts from an owned validated info dictionary.

§Errors

Returns an error when info is not a dictionary.

Source

pub fn trackers(self, tiers: impl IntoIterator<Item = Vec<Vec<u8>>>) -> Self

Replaces tracker tiers.

Source

pub fn web_seeds(self, seeds: impl IntoIterator<Item = Vec<u8>>) -> Self

Replaces web seed URLs.

Source

pub fn nodes(self, nodes: impl IntoIterator<Item = (Vec<u8>, u16)>) -> Self

Replaces DHT bootstrap nodes.

Source

pub fn comment(self, value: Option<Vec<u8>>) -> Self

Sets or removes the top-level comment.

Source

pub fn created_by(self, value: Option<Vec<u8>>) -> Self

Sets or removes the top-level creator.

Source

pub fn creation_date(self, value: Option<i64>) -> Self

Sets or removes the top-level creation timestamp.

Source

pub fn private(self, value: Option<bool>) -> Self

Sets or removes the private flag inside info.

Source

pub fn source(self, value: Option<Vec<u8>>) -> Self

Sets or removes the source field inside info.

Source

pub fn raw_top_level(self, key: Vec<u8>, value: OwnedValue) -> Result<Self>

Adds or replaces an unknown top-level extension.

§Errors

Returns an error for reserved keys.

Source

pub fn file_attributes( self, path: &[Vec<u8>], attributes: Vec<u8>, ) -> Result<Self>

Sets file attributes for a validated v1 or v2 path.

§Errors

Returns an error when the path is absent or has an unsupported shape.

Source

pub fn to_metainfo(self) -> Result<Metainfo>

Serializes top-level fields canonically and validates the edited result.

Untouched info bytes retain their exact source encoding. Any info-level edit canonicalizes the updated info dictionary. Calling Metainfo::to_bytes on the result explicitly canonicalizes the complete metainfo object.

§Errors

Returns serialization or protocol validation errors.

Trait Implementations§

Source§

impl Clone for MetainfoEditor

Source§

fn clone(&self) -> MetainfoEditor

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MetainfoEditor

Source§

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

Formats the value using the given formatter. Read more

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

Source§

type Output = T

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