Skip to main content

StorePathNameBuf

Struct StorePathNameBuf 

Source
pub struct StorePathNameBuf(SmolStr);
Expand description

An owned 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: SmolStr

Implementations§

Source§

impl StorePathNameBuf

Source

pub const fn max_len() -> usize

Maximum number of bytes in a store path name.

Source

pub fn source() -> StorePathNameBuf

Return default name of sources.

§Examples
assert_eq!(StorePathNameBuf::source(), "source");
Source

pub fn from_string(name: String) -> Result<Self, ParseStorePathNameError>

Checks a given String to match the restrictions for store path names, and returns the name as StorePathNameBuf if successful.

Source

pub fn from_smol_str(name: SmolStr) -> Result<Self, ParseStorePathNameError>

Checks a given SmolStr to match the restrictions for store path names, and returns the name as StorePathNameBuf if successful.

Source

pub fn from_slice(name: &[u8]) -> Result<Self, ParseStorePathNameError>

Checks a given &[u8] to match the restrictions for store path names, and returns the name as StorePathNameBuf if successful.

Source

pub fn as_name(&self) -> &StorePathName

Coerces to a StorePathName slice.

§Examples
let name = StorePathNameBuf::try_from("snix-build").unwrap();
assert_eq!(StorePathName::from_str("snix-build").unwrap(), name.as_name());

Methods from Deref<Target = StorePathName>§

Source

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");
Source

pub fn is_drv(&self) -> bool

Returns true if this is the name of a derivation.

Derivation names always end in .drv and has len() longer than 4.

§Examples
let n = StorePathName::from_str("snix-eval").unwrap();
assert!(!n.is_drv());

let b = n.build_drv_name().unwrap();
assert!(b.is_drv());
Source

pub fn strip_drv_ext(&self) -> Option<&StorePathName>

Remove .drv extension from this name or return None if this is not a derivation name.

Source

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.

Source

pub fn len(&self) -> usize

Returns the length of this name.

§Examples
assert_eq!(6, StorePathName::source().len());
Source

pub 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);
Source

pub fn as_bytes(&self) -> &[u8] ⓘ

Converts a name to a byte slice. To convert the byte slice back into a name, use the Self::from_slice function.

§Examples
let bytes = StorePathName::source().as_bytes();
assert_eq!(b"source", bytes);

Trait Implementations§

Source§

impl AsRef<StorePathName> for StorePathNameBuf

Source§

fn as_ref(&self) -> &StorePathName

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<str> for StorePathNameBuf

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<StorePathName> for StorePathNameBuf

Source§

fn borrow(&self) -> &StorePathName

Immutably borrows from an owned value. Read more
Source§

impl Clone for StorePathNameBuf

Source§

fn clone(&self) -> StorePathNameBuf

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StorePathNameBuf

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StorePathNameBuf

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for StorePathNameBuf

Source§

type Target = StorePathName

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Display for StorePathNameBuf

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a StorePathName> for StorePathNameBuf

Source§

fn from(value: &'a StorePathName) -> Self

Converts to this type from the input type.
Source§

impl FromStr for StorePathNameBuf

Source§

type Err = ParseStorePathNameError

The associated error which can be returned from parsing.
Source§

fn from_str(name: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for StorePathNameBuf

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq<&StorePathName> for StorePathNameBuf

Source§

fn eq(&self, other: &&StorePathName) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&str> for StorePathNameBuf

Source§

fn eq(&self, other: &&str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<StorePathNameBuf> for &StorePathName

Source§

fn eq(&self, other: &StorePathNameBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<StorePathNameBuf> for &str

Source§

fn eq(&self, other: &StorePathNameBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<StorePathNameBuf> for String

Source§

fn eq(&self, other: &StorePathNameBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<StorePathNameBuf> for str

Source§

fn eq(&self, other: &StorePathNameBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<String> for StorePathNameBuf

Source§

fn eq(&self, other: &String) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for StorePathNameBuf

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for StorePathNameBuf

Source§

fn eq(&self, other: &StorePathNameBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&[u8]> for StorePathNameBuf

Source§

type Error = ParseStorePathNameError

The type returned in the event of a conversion error.
Source§

fn try_from(name: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&str> for StorePathNameBuf

Source§

type Error = ParseStorePathNameError

The type returned in the event of a conversion error.
Source§

fn try_from(name: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<SmolStr> for StorePathNameBuf

Source§

type Error = ParseStorePathNameError

The type returned in the event of a conversion error.
Source§

fn try_from(name: SmolStr) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<String> for StorePathNameBuf

Source§

type Error = ParseStorePathNameError

The type returned in the event of a conversion error.
Source§

fn try_from(name: String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for StorePathNameBuf

Source§

impl StructuralPartialEq for StorePathNameBuf

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more