Skip to main content

StorePath

Struct StorePath 

Source
pub struct StorePath { /* private fields */ }
Expand description

A path in the Nix store.

Represents a store path that can be realized or queried.

Implementations§

Source§

impl StorePath

Source

pub fn parse(context: &Arc<Context>, store: &Store, path: &str) -> Result<Self>

Parse a store path string into a StorePath.

§Arguments
  • context - The Nix context
  • store - The store containing the path
  • path - The store path string (e.g., "/nix/store/...")
§Errors

Returns an error if the path string is not a valid store path.

Source

pub fn name(&self) -> Result<String>

Get the name component of the store path.

Returns the name part of the store path (everything after the hash). For example, for "/nix/store/abc123...-hello-1.0" this returns "hello-1.0".

§Errors

Returns an error if the name cannot be retrieved.

Source

pub fn hash_part(&self) -> Result<[u8; 20]>

Get the hash component of the store path as raw bytes.

The 20-byte hash is decoded from the “nix32” encoding in the store path. For example, for "/nix/store/abc123...-hello-1.0" this returns the raw hash bytes corresponding to "abc123...".

§Returns

The raw 20-byte hash.

§Errors

Returns an error if the hash cannot be retrieved.

Source

pub fn from_parts( context: &Arc<Context>, hash: &[u8; 20], name: &str, ) -> Result<Self>

Create a StorePath from its constituent hash and name parts.

Unlike parse, this does not require a Store reference or the /nix/store prefix.

§Arguments
  • hash - The 20-byte raw hash (as produced by hash_part).
  • name - The name component (e.g., "hello-1.0").
§Returns

A new StorePath.

§Errors

Returns an error if the path cannot be created.

Trait Implementations§

Source§

impl Clone for StorePath

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StorePath

Source§

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

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

impl Display for StorePath

Renders the name component only (e.g. hello-1.0), not the canonical /nix/store/<hash>-<name> string.

The Nix C API does not expose a store-directory-aware print function; without a Store handle there is no way to recover the full path. Use Store::print_path (requires the shim feature) when you need the canonical form.

Source§

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

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

impl Drop for StorePath

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for StorePath

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<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> 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.