pub enum FileTreeNode {
File(V2FileAttr),
Directory(BTreeMap<String, Self>),
}Expand description
A node in the v2 file tree — either a file or a directory.
Variants§
File(V2FileAttr)
A file with its attributes.
Directory(BTreeMap<String, Self>)
A directory containing named children.
Implementations§
Source§impl FileTreeNode
impl FileTreeNode
Sourcepub fn from_bencode(value: &BencodeValue) -> Result<Self, Error>
pub fn from_bencode(value: &BencodeValue) -> Result<Self, Error>
Parse a file tree node from a BencodeValue.
A node is a dict. If it contains a "" key, it’s a file node (the ""
value holds file attributes). Otherwise, each key is a directory entry
name and its value is a child FileTreeNode.
§Errors
Returns an error if the bencode value is not a valid file tree node.
Sourcepub fn flatten(&self) -> Vec<V2FileInfo>
pub fn flatten(&self) -> Vec<V2FileInfo>
Recursively flatten the tree into a list of files with full paths.
Sourcepub fn to_bencode(&self) -> BencodeValue
pub fn to_bencode(&self) -> BencodeValue
Convert a file tree back to a BencodeValue for serialization.
Used by hybrid torrent creation to build the merged info dict.
Trait Implementations§
Source§impl Clone for FileTreeNode
impl Clone for FileTreeNode
Source§fn clone(&self) -> FileTreeNode
fn clone(&self) -> FileTreeNode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FileTreeNode
impl Debug for FileTreeNode
Source§impl PartialEq for FileTreeNode
impl PartialEq for FileTreeNode
Source§fn eq(&self, other: &FileTreeNode) -> bool
fn eq(&self, other: &FileTreeNode) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for FileTreeNode
impl StructuralPartialEq for FileTreeNode
Auto Trait Implementations§
impl Freeze for FileTreeNode
impl RefUnwindSafe for FileTreeNode
impl Send for FileTreeNode
impl Sync for FileTreeNode
impl Unpin for FileTreeNode
impl UnsafeUnpin for FileTreeNode
impl UnwindSafe for FileTreeNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more