pub struct StorePath { /* private fields */ }Implementations§
Source§impl StorePath
impl StorePath
Sourcepub fn name(&self) -> Result<String>
pub fn name(&self) -> Result<String>
Get the name of the store path.
For a store path like /nix/store/abc1234...-foo-1.2, this function will return foo-1.2.
Sourcepub fn hash(&self) -> Result<[u8; 20]>
pub fn hash(&self) -> Result<[u8; 20]>
Get the hash part of the store path.
This returns the decoded hash (not the nix32-encoded string).
Sourcepub fn from_parts(hash: &[u8; 20], name: &str) -> Result<Self>
pub fn from_parts(hash: &[u8; 20], name: &str) -> Result<Self>
Create a StorePath from hash and name components.
Sourcepub unsafe fn new_raw_clone(raw: NonNull<StorePath>) -> Self
pub unsafe fn new_raw_clone(raw: NonNull<StorePath>) -> Self
This is a low level function that you shouldn’t have to call unless you are developing the Nix bindings.
Construct a new StorePath by first cloning the C store path.
§Safety
This does not take ownership of the C store path, so it should be a borrowed pointer, or you should free it.
Sourcepub unsafe fn new_raw(raw: NonNull<StorePath>) -> Self
pub unsafe fn new_raw(raw: NonNull<StorePath>) -> Self
This is a low level function that you shouldn’t have to call unless you are developing the Nix bindings.
Takes ownership of a C nix_store_path. It will be freed when the StorePath is dropped.
§Safety
The caller must ensure that the provided NonNull<raw::StorePath> is valid and that the ownership
semantics are correctly followed. The raw pointer must not be used after being passed to this function.
Sourcepub unsafe fn as_ptr(&self) -> *mut StorePath
pub unsafe fn as_ptr(&self) -> *mut StorePath
This is a low level function that you shouldn’t have to call unless you are developing the Nix bindings.
Get a pointer to the underlying Nix C API store path.
§Safety
This function is unsafe because it returns a raw pointer. The caller must ensure that the pointer is not used beyond the lifetime of this StorePath.