pub struct TargetName(/* private fields */);Expand description
Validated target name.
Implementations§
Source§impl TargetName
impl TargetName
Sourcepub fn new(value: impl Into<String>) -> Result<Self, ValidationError>
pub fn new(value: impl Into<String>) -> Result<Self, ValidationError>
Construct a TargetName after running validation.
Target names are joined into filesystem paths by the build
planner (object directories, executable paths, Cargo target
directories), so they share the path-component grammar with
PackageName: a name like [target."../escape"] would
otherwise let a malicious manifest write artifacts outside
the selected --build-dir. The grammar is enforced through
is_path_safe_package_name, which already covers path
separators, .. / ., leading . or -, control characters,
non-ASCII bytes, and Windows-reserved filename characters in a
single rule.
§Errors
Returns ValidationError::EmptyTargetName for an empty name,
ValidationError::TargetNameContainsWhitespace when the name contains
whitespace, and ValidationError::UnsafeTargetName when it fails the
is_path_safe_package_name predicate.
pub fn as_str(&self) -> &str
Trait Implementations§
Source§impl AsRef<str> for TargetName
impl AsRef<str> for TargetName
Source§impl Clone for TargetName
impl Clone for TargetName
Source§fn clone(&self) -> TargetName
fn clone(&self) -> TargetName
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TargetName
impl Debug for TargetName
Source§impl<'de> Deserialize<'de> for TargetName
impl<'de> Deserialize<'de> for TargetName
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for TargetName
impl Display for TargetName
Source§impl From<TargetName> for String
impl From<TargetName> for String
Source§fn from(value: TargetName) -> Self
fn from(value: TargetName) -> Self
Source§impl Hash for TargetName
impl Hash for TargetName
Source§impl Ord for TargetName
impl Ord for TargetName
Source§fn cmp(&self, other: &TargetName) -> Ordering
fn cmp(&self, other: &TargetName) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for TargetName
impl PartialEq for TargetName
Source§fn eq(&self, other: &TargetName) -> bool
fn eq(&self, other: &TargetName) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for TargetName
impl PartialOrd for TargetName
Source§impl Serialize for TargetName
impl Serialize for TargetName
Source§impl TryFrom<String> for TargetName
impl TryFrom<String> for TargetName
impl Eq for TargetName
impl StructuralPartialEq for TargetName
Auto Trait Implementations§
impl Freeze for TargetName
impl RefUnwindSafe for TargetName
impl Send for TargetName
impl Sync for TargetName
impl Unpin for TargetName
impl UnsafeUnpin for TargetName
impl UnwindSafe for TargetName
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.