pub struct TorrentPath(/* private fields */);Expand description
Owned torrent path preserving raw component identity and ordering.
Implementations§
Source§impl TorrentPath
impl TorrentPath
Sourcepub fn new(components: impl IntoIterator<Item = TorrentBytes>) -> Result<Self>
pub fn new(components: impl IntoIterator<Item = TorrentBytes>) -> Result<Self>
Creates a path after validating every raw component.
§Errors
Returns a metainfo error when the path is empty or a component is unsafe.
Sourcepub fn components(&self) -> &[TorrentBytes]
pub fn components(&self) -> &[TorrentBytes]
Returns raw path components.
Sourcepub fn utf8_components(&self) -> Option<Vec<&str>>
pub fn utf8_components(&self) -> Option<Vec<&str>>
Returns UTF-8 components only when every component decodes losslessly.
Sourcepub fn to_path_buf(&self) -> Result<PathBuf>
pub fn to_path_buf(&self) -> Result<PathBuf>
Converts to a platform path only when the conversion is lossless.
§Errors
Returns unsupported on platforms that cannot represent a non-UTF-8 component without replacement.
Trait Implementations§
Source§impl Clone for TorrentPath
impl Clone for TorrentPath
Source§fn clone(&self) -> TorrentPath
fn clone(&self) -> TorrentPath
Returns a duplicate of the value. Read more
1.0.0 · 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 TorrentPath
impl Debug for TorrentPath
Source§impl Hash for TorrentPath
impl Hash for TorrentPath
Source§impl Ord for TorrentPath
impl Ord for TorrentPath
Source§fn cmp(&self, other: &TorrentPath) -> Ordering
fn cmp(&self, other: &TorrentPath) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for TorrentPath
impl PartialEq for TorrentPath
Source§impl PartialOrd for TorrentPath
impl PartialOrd for TorrentPath
impl Eq for TorrentPath
impl StructuralPartialEq for TorrentPath
Auto Trait Implementations§
impl Freeze for TorrentPath
impl RefUnwindSafe for TorrentPath
impl Send for TorrentPath
impl Sync for TorrentPath
impl Unpin for TorrentPath
impl UnwindSafe for TorrentPath
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