pub struct MetainfoEditor { /* private fields */ }Expand description
Owned metainfo editor preserving untouched known and unknown fields.
Implementations§
Source§impl MetainfoEditor
impl MetainfoEditor
Sourcepub fn from_metainfo(metainfo: &Metainfo) -> Result<Self>
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.
Sourcepub fn from_info(info: OwnedValue) -> Result<Self>
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.
Sourcepub fn trackers(self, tiers: impl IntoIterator<Item = Vec<Vec<u8>>>) -> Self
pub fn trackers(self, tiers: impl IntoIterator<Item = Vec<Vec<u8>>>) -> Self
Replaces tracker tiers.
Sourcepub fn web_seeds(self, seeds: impl IntoIterator<Item = Vec<u8>>) -> Self
pub fn web_seeds(self, seeds: impl IntoIterator<Item = Vec<u8>>) -> Self
Replaces web seed URLs.
Sourcepub fn nodes(self, nodes: impl IntoIterator<Item = (Vec<u8>, u16)>) -> Self
pub fn nodes(self, nodes: impl IntoIterator<Item = (Vec<u8>, u16)>) -> Self
Replaces DHT bootstrap nodes.
Sourcepub fn created_by(self, value: Option<Vec<u8>>) -> Self
pub fn created_by(self, value: Option<Vec<u8>>) -> Self
Sets or removes the top-level creator.
Sourcepub fn creation_date(self, value: Option<i64>) -> Self
pub fn creation_date(self, value: Option<i64>) -> Self
Sets or removes the top-level creation timestamp.
Sourcepub fn private(self, value: Option<bool>) -> Self
pub fn private(self, value: Option<bool>) -> Self
Sets or removes the private flag inside info.
Sourcepub fn source(self, value: Option<Vec<u8>>) -> Self
pub fn source(self, value: Option<Vec<u8>>) -> Self
Sets or removes the source field inside info.
Sourcepub fn raw_top_level(self, key: Vec<u8>, value: OwnedValue) -> Result<Self>
pub fn raw_top_level(self, key: Vec<u8>, value: OwnedValue) -> Result<Self>
Sourcepub fn file_attributes(
self,
path: &[Vec<u8>],
attributes: Vec<u8>,
) -> Result<Self>
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.
Sourcepub fn to_metainfo(self) -> Result<Metainfo>
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
impl Clone for MetainfoEditor
Source§fn clone(&self) -> MetainfoEditor
fn clone(&self) -> MetainfoEditor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more