diff --git a/rust/nix-store/src/path.rs b/rust/nix-store/src/path.rs index fc20382..a0cb301 100644 --- a/rust/nix-store/src/path.rs +++ b/rust/nix-store/src/path.rs @@ -11,6 +11,21 @@ pub struct StorePath { raw: NonNull, } 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 { + 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) -> Self { StorePath { raw } } - pub fn name(&self) -> Result { - 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. ///