From 9a6ef0489ef85e3089f3d352d937bb4144097196 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 22 May 2024 14:01:36 +0200 Subject: [PATCH] doc: Clarify ownership around StorePath::new_* (cherry picked from commit 397f00e8eefff376759f05bd0cbaecc106c681df) --- rust/nix-store/src/path.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rust/nix-store/src/path.rs b/rust/nix-store/src/path.rs index 1a7350c..f8ca699 100644 --- a/rust/nix-store/src/path.rs +++ b/rust/nix-store/src/path.rs @@ -6,9 +6,20 @@ pub struct StorePath { raw: *mut raw::StorePath, } impl StorePath { + /** + * 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. + * This does not take ownership of the C store path, so it should be a borrowed value, or you should free it. + */ pub fn new_raw_clone(raw: *const raw::StorePath) -> Self { Self::new_raw(unsafe { raw::store_path_clone(raw as *mut raw::StorePath) }) } + /** + * 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. + */ pub fn new_raw(raw: *mut raw::StorePath) -> Self { StorePath { raw } }