pub struct MetadataPath(/* private fields */);Expand description
Wrapper for a path to metadata.
Note: This should not contain the file extension. This is automatically added by the library depending on what type of data pouf format is being used.
use tuf::metadata::MetadataPath;
// right
let _ = MetadataPath::new("root");
// wrong
let _ = MetadataPath::new("root.json");Implementations§
Source§impl MetadataPath
impl MetadataPath
Sourcepub fn new<P: Into<Cow<'static, str>>>(path: P) -> Result<Self>
pub fn new<P: Into<Cow<'static, str>>>(path: P) -> Result<Self>
Create a new MetadataPath from a String.
assert!(MetadataPath::new("foo").is_ok());
assert!(MetadataPath::new("/foo").is_err());
assert!(MetadataPath::new("../foo").is_err());
assert!(MetadataPath::new("foo/..").is_err());
assert!(MetadataPath::new("foo/../bar").is_err());
assert!(MetadataPath::new("..foo").is_ok());
assert!(MetadataPath::new("foo/..bar").is_ok());
assert!(MetadataPath::new("foo/bar..").is_ok());Sourcepub fn components<D>(&self, version: MetadataVersion) -> Vec<String>where
D: Pouf,
pub fn components<D>(&self, version: MetadataVersion) -> Vec<String>where
D: Pouf,
Split MetadataPath into components that can be joined to create URL paths, Unix paths, or
Windows paths.
let path = MetadataPath::new("foo/bar").unwrap();
assert_eq!(path.components::<Pouf1>(MetadataVersion::None),
["foo".to_string(), "bar.json".to_string()]);
assert_eq!(path.components::<Pouf1>(MetadataVersion::Number(1)),
["foo".to_string(), "1.bar.json".to_string()]);Trait Implementations§
Source§impl Clone for MetadataPath
impl Clone for MetadataPath
Source§fn clone(&self) -> MetadataPath
fn clone(&self) -> MetadataPath
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 MetadataPath
impl Debug for MetadataPath
Source§impl<'de> Deserialize<'de> for MetadataPath
impl<'de> Deserialize<'de> for MetadataPath
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 MetadataPath
impl Display for MetadataPath
Source§impl From<Role> for MetadataPath
impl From<Role> for MetadataPath
Source§fn from(role: Role) -> MetadataPath
fn from(role: Role) -> MetadataPath
Converts to this type from the input type.
Source§impl Hash for MetadataPath
impl Hash for MetadataPath
Source§impl Ord for MetadataPath
impl Ord for MetadataPath
Source§fn cmp(&self, other: &MetadataPath) -> Ordering
fn cmp(&self, other: &MetadataPath) -> 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 MetadataPath
impl PartialEq for MetadataPath
Source§impl PartialOrd for MetadataPath
impl PartialOrd for MetadataPath
Source§impl Serialize for MetadataPath
impl Serialize for MetadataPath
impl Eq for MetadataPath
impl StructuralPartialEq for MetadataPath
Auto Trait Implementations§
impl Freeze for MetadataPath
impl RefUnwindSafe for MetadataPath
impl Send for MetadataPath
impl Sync for MetadataPath
impl Unpin for MetadataPath
impl UnsafeUnpin for MetadataPath
impl UnwindSafe for MetadataPath
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