pub struct ProfileName(/* private fields */);Expand description
Validated profile name.
Profile names appear in three places: the manifest TOML key
([profile.<name>]), the CLI flag (--profile <name>), and
the on-disk build directory layout
(<build_dir>/<profile>/...). The grammar below is the
intersection of those three constraints so a single value can
flow through all of them without per-stage re-validation.
Implementations§
Source§impl ProfileName
impl ProfileName
Sourcepub fn new(value: impl Into<String>) -> Result<Self, InvalidProfileName>
pub fn new(value: impl Into<String>) -> Result<Self, InvalidProfileName>
Construct a ProfileName after running validation.
A name is valid iff:
- it is non-empty;
- it consists only of ASCII alphanumerics,
_,-,.; - it does not start with
.; - it is not literally
.or...
§Errors
Returns InvalidProfileName when value fails the
is_path_safe_profile_name predicate above.
Sourcepub fn builtin(profile: BuiltinProfile) -> Self
pub fn builtin(profile: BuiltinProfile) -> Self
Construct a ProfileName for one of Cabin’s two built-ins.
Built-in names are guaranteed valid so this never fails.
pub fn as_str(&self) -> &str
Sourcepub fn as_builtin(&self) -> Option<BuiltinProfile>
pub fn as_builtin(&self) -> Option<BuiltinProfile>
Returns the matching BuiltinProfile when this name
refers to a built-in.
Trait Implementations§
Source§impl AsRef<str> for ProfileName
impl AsRef<str> for ProfileName
Source§impl Borrow<str> for ProfileName
impl Borrow<str> for ProfileName
Source§impl Clone for ProfileName
impl Clone for ProfileName
Source§fn clone(&self) -> ProfileName
fn clone(&self) -> ProfileName
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 ProfileName
impl Debug for ProfileName
Source§impl<'de> Deserialize<'de> for ProfileName
impl<'de> Deserialize<'de> for ProfileName
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ProfileName
impl Display for ProfileName
Source§impl From<ProfileName> for String
impl From<ProfileName> for String
Source§fn from(name: ProfileName) -> Self
fn from(name: ProfileName) -> Self
Converts to this type from the input type.
Source§impl Hash for ProfileName
impl Hash for ProfileName
Source§impl Ord for ProfileName
impl Ord for ProfileName
Source§fn cmp(&self, other: &ProfileName) -> Ordering
fn cmp(&self, other: &ProfileName) -> Ordering
1.21.0 (const: unstable) · 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 ProfileName
impl PartialEq for ProfileName
Source§fn eq(&self, other: &ProfileName) -> bool
fn eq(&self, other: &ProfileName) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ProfileName
impl PartialOrd for ProfileName
Source§impl Serialize for ProfileName
impl Serialize for ProfileName
Source§impl TryFrom<String> for ProfileName
impl TryFrom<String> for ProfileName
impl Eq for ProfileName
impl StructuralPartialEq for ProfileName
Auto Trait Implementations§
impl Freeze for ProfileName
impl RefUnwindSafe for ProfileName
impl Send for ProfileName
impl Sync for ProfileName
impl Unpin for ProfileName
impl UnsafeUnpin for ProfileName
impl UnwindSafe for ProfileName
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
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
Compare self to
key and return true if they are equal.