doc: StorePath.name()

(cherry picked from commit 2f3dc27eb816634ebb8edbabd409ebc52db9a0bb)
This commit is contained in:
Robert Hensing 2024-12-17 09:37:18 +01:00
parent ce07ed1c07
commit 3d3c77eced

View file

@ -11,6 +11,21 @@ pub struct StorePath {
raw: NonNull<raw::StorePath>,
}
impl StorePath {
/// 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`.
pub fn name(&self) -> Result<String> {
unsafe {
let mut r = result_string_init!();
raw::store_path_name(
self.as_ptr(),
Some(callback_get_result_string),
callback_get_result_string_data(&mut r),
);
r
}
}
/// 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.
@ -37,17 +52,6 @@ impl StorePath {
pub unsafe fn new_raw(raw: NonNull<raw::StorePath>) -> Self {
StorePath { raw }
}
pub fn name(&self) -> Result<String> {
unsafe {
let mut r = result_string_init!();
raw::store_path_name(
self.as_ptr(),
Some(callback_get_result_string),
callback_get_result_string_data(&mut r),
);
r
}
}
/// This is a low level function that you shouldn't have to call unless you are developing the Nix bindings.
///