#[repr(transparent)]pub struct StorePathName(str);Expand description
Validated name of a store path.
The name may only contain ASCII alphanumeric, or one of the following
characters: -, _, ., +, ?, = and must be shorter than 211 characters long.
Tuple Fields§
§0: strImplementations§
Source§impl StorePathName
impl StorePathName
Sourcepub const fn source() -> &'static StorePathName
pub const fn source() -> &'static StorePathName
Sourcepub const unsafe fn from_str_unchecked(name: &str) -> &StorePathName
pub const unsafe fn from_str_unchecked(name: &str) -> &StorePathName
Converts a str to a StorePathName without checking that it is a valid name.
§Safety
This function is unsafe because it does not check that the str passed to it is a
valid store path name. If this constraint is violated it may cause panics and memory safety
issues , as the rest of snix assumes that StorePathName contains a valid store path name.
Sourcepub fn from_str(name: &str) -> Result<&StorePathName, ParseStorePathNameError>
pub fn from_str(name: &str) -> Result<&StorePathName, ParseStorePathNameError>
Checks a given &str to match the restrictions for StorePathName, and
returns the name as &StorePathName if successful.
Sourcepub fn from_slice(
name: &[u8],
) -> Result<&StorePathName, ParseStorePathNameError>
pub fn from_slice( name: &[u8], ) -> Result<&StorePathName, ParseStorePathNameError>
Checks a given &[u8] to match the restrictions for StorePathName, and
returns the name as &StorePathName if successful.
Sourcepub fn from_os_str(
name: &OsStr,
) -> Result<&StorePathName, ParseStorePathNameError>
pub fn from_os_str( name: &OsStr, ) -> Result<&StorePathName, ParseStorePathNameError>
Checks a given OsStr to match the restrictions for StorePathName, and
returns the name as &StorePathName if successful
Sourcepub fn build_drv_name(
&self,
) -> Result<StorePathNameBuf, ParseStorePathNameError>
pub fn build_drv_name( &self, ) -> Result<StorePathNameBuf, ParseStorePathNameError>
Build a new StorePathNameBuf by adding .drv extension to this StorePathName. This
fails if this name already ends in .drv or the resulting name would be too long.
§Examples
let n = StorePathName::from_str("snix-eval").unwrap();
assert_eq!(n.build_drv_name().unwrap(), "snix-eval.drv");Sourcepub fn strip_drv_ext(&self) -> Option<&StorePathName>
pub fn strip_drv_ext(&self) -> Option<&StorePathName>
Remove .drv extension from this name or return None if this is not a derivation name.
Sourcepub fn strip_suffix(&self, suffix: &str) -> Option<&StorePathName>
pub fn strip_suffix(&self, suffix: &str) -> Option<&StorePathName>
Strip a suffix from this name or return None if the resulting name would have been empty.
Sourcepub const fn as_str(&self) -> &str
pub const fn as_str(&self) -> &str
Converts a name to a string. To convert the string back into a name,
use the Self::from_str function.
§Examples
let s = StorePathName::source().as_str();
assert_eq!("source", s);Trait Implementations§
Source§impl AsRef<[u8]> for StorePathName
impl AsRef<[u8]> for StorePathName
Source§impl AsRef<StorePathName> for StorePathName
impl AsRef<StorePathName> for StorePathName
Source§fn as_ref(&self) -> &StorePathName
fn as_ref(&self) -> &StorePathName
Source§impl AsRef<StorePathName> for StorePathNameBuf
impl AsRef<StorePathName> for StorePathNameBuf
Source§fn as_ref(&self) -> &StorePathName
fn as_ref(&self) -> &StorePathName
Source§impl AsRef<str> for StorePathName
impl AsRef<str> for StorePathName
Source§impl Borrow<StorePathName> for StorePathNameBuf
impl Borrow<StorePathName> for StorePathNameBuf
Source§fn borrow(&self) -> &StorePathName
fn borrow(&self) -> &StorePathName
Source§impl Debug for StorePathName
impl Debug for StorePathName
Source§impl Display for StorePathName
impl Display for StorePathName
Source§impl<'a> From<&'a StorePathName> for StorePathNameBuf
impl<'a> From<&'a StorePathName> for StorePathNameBuf
Source§fn from(value: &'a StorePathName) -> Self
fn from(value: &'a StorePathName) -> Self
Source§impl Hash for StorePathName
impl Hash for StorePathName
Source§impl PartialEq<&StorePathName> for StorePathNameBuf
impl PartialEq<&StorePathName> for StorePathNameBuf
Source§fn eq(&self, other: &&StorePathName) -> bool
fn eq(&self, other: &&StorePathName) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialEq<&str> for StorePathName
impl PartialEq<&str> for StorePathName
Source§impl PartialEq<StorePathName> for &str
impl PartialEq<StorePathName> for &str
Source§fn eq(&self, other: &StorePathName) -> bool
fn eq(&self, other: &StorePathName) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialEq<StorePathName> for String
impl PartialEq<StorePathName> for String
Source§fn eq(&self, other: &StorePathName) -> bool
fn eq(&self, other: &StorePathName) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialEq<StorePathName> for str
impl PartialEq<StorePathName> for str
Source§fn eq(&self, other: &StorePathName) -> bool
fn eq(&self, other: &StorePathName) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialEq<StorePathNameBuf> for &StorePathName
impl PartialEq<StorePathNameBuf> for &StorePathName
Source§fn eq(&self, other: &StorePathNameBuf) -> bool
fn eq(&self, other: &StorePathNameBuf) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialEq<String> for StorePathName
impl PartialEq<String> for StorePathName
Source§impl PartialEq<str> for StorePathName
impl PartialEq<str> for StorePathName
Source§impl PartialEq for StorePathName
impl PartialEq for StorePathName
Source§fn eq(&self, other: &StorePathName) -> bool
fn eq(&self, other: &StorePathName) -> bool
self and other values to be equal, and is used by ==.Source§impl ToOwned for StorePathName
impl ToOwned for StorePathName
Source§type Owned = StorePathNameBuf
type Owned = StorePathNameBuf
Source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Source§impl<'a> TryFrom<&'a [u8]> for &'a StorePathName
impl<'a> TryFrom<&'a [u8]> for &'a StorePathName
Source§impl<'a> TryFrom<&'a str> for &'a StorePathName
impl<'a> TryFrom<&'a str> for &'a StorePathName
impl Eq for StorePathName
impl StructuralPartialEq for StorePathName
Auto Trait Implementations§
impl Freeze for StorePathName
impl RefUnwindSafe for StorePathName
impl Send for StorePathName
impl !Sized for StorePathName
impl Sync for StorePathName
impl Unpin for StorePathName
impl UnsafeUnpin for StorePathName
impl UnwindSafe for StorePathName
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<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.