pub struct TargetPath(/* private fields */);Expand description
Wrapper for the virtual path to a target.
Implementations§
Source§impl TargetPath
impl TargetPath
Sourcepub fn new<P: Into<String>>(path: P) -> Result<Self>
pub fn new<P: Into<String>>(path: P) -> Result<Self>
Create a new TargetPath from a String.
assert!(TargetPath::new("foo").is_ok());
assert!(TargetPath::new("/foo").is_err());
assert!(TargetPath::new("../foo").is_err());
assert!(TargetPath::new("foo/..").is_err());
assert!(TargetPath::new("foo/../bar").is_err());
assert!(TargetPath::new("..foo").is_ok());
assert!(TargetPath::new("foo/..bar").is_ok());
assert!(TargetPath::new("foo/bar..").is_ok());Sourcepub fn components(&self) -> Vec<String>
pub fn components(&self) -> Vec<String>
Split TargetPath into components that can be joined to create URL paths, Unix
paths, or Windows paths.
let path = TargetPath::new("foo/bar").unwrap();
assert_eq!(path.components(), ["foo".to_string(), "bar".to_string()]);Sourcepub fn is_child(&self, parent: &Self) -> bool
pub fn is_child(&self, parent: &Self) -> bool
Return whether this path is the child of another path.
let path1 = TargetPath::new("foo").unwrap();
let path2 = TargetPath::new("foo/bar").unwrap();
assert!(!path2.is_child(&path1));
let path1 = TargetPath::new("foo/").unwrap();
let path2 = TargetPath::new("foo/bar").unwrap();
assert!(path2.is_child(&path1));
let path2 = TargetPath::new("foo/bar/baz").unwrap();
assert!(path2.is_child(&path1));
let path2 = TargetPath::new("wat").unwrap();
assert!(!path2.is_child(&path1))Sourcepub fn matches_chain(&self, parents: &[HashSet<TargetPath>]) -> bool
pub fn matches_chain(&self, parents: &[HashSet<TargetPath>]) -> bool
Whether or not the current target is available at the end of the given chain of target paths. For the chain to be valid, each target path in a group must be a child of of all previous groups.
Sourcepub fn with_hash_prefix(&self, hash: &HashValue) -> Result<TargetPath>
pub fn with_hash_prefix(&self, hash: &HashValue) -> Result<TargetPath>
Prefix the target path with a hash value to support TUF spec 5.5.2.
Trait Implementations§
Source§impl Borrow<str> for TargetPath
impl Borrow<str> for TargetPath
Source§impl Clone for TargetPath
impl Clone for TargetPath
Source§fn clone(&self) -> TargetPath
fn clone(&self) -> TargetPath
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 TargetPath
impl Debug for TargetPath
Source§impl<'de> Deserialize<'de> for TargetPath
impl<'de> Deserialize<'de> for TargetPath
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for TargetPath
impl Display for TargetPath
Source§impl Hash for TargetPath
impl Hash for TargetPath
Source§impl Ord for TargetPath
impl Ord for TargetPath
Source§fn cmp(&self, other: &TargetPath) -> Ordering
fn cmp(&self, other: &TargetPath) -> 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 TargetPath
impl PartialEq for TargetPath
Source§impl PartialOrd for TargetPath
impl PartialOrd for TargetPath
Source§impl Serialize for TargetPath
impl Serialize for TargetPath
impl Eq for TargetPath
impl StructuralPartialEq for TargetPath
Auto Trait Implementations§
impl Freeze for TargetPath
impl RefUnwindSafe for TargetPath
impl Send for TargetPath
impl Sync for TargetPath
impl Unpin for TargetPath
impl UnsafeUnpin for TargetPath
impl UnwindSafe for TargetPath
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