2025-04-02 18:49:03 +02:00
|
|
|
//! Functions that are relevant for other bindings modules, but normally not end users.
|
|
|
|
|
use super::Value;
|
2026-01-12 19:56:04 +01:00
|
|
|
use nix_bindings_util_sys as raw;
|
2025-04-02 18:49:03 +02:00
|
|
|
|
2025-12-16 02:05:44 +01:00
|
|
|
/// Take ownership of a new [`Value`].
|
|
|
|
|
///
|
|
|
|
|
/// This does not call `nix_gc_incref`, but does call `nix_gc_decref` when dropped.
|
2025-12-15 19:48:30 -05:00
|
|
|
///
|
|
|
|
|
/// # Safety
|
|
|
|
|
///
|
2025-12-16 02:05:44 +01:00
|
|
|
/// The caller must ensure that the provided `ptr` has a positive reference count,
|
|
|
|
|
/// and that `ptr` is not used after the returned `Value` is dropped.
|
2025-04-02 18:49:03 +02:00
|
|
|
pub unsafe fn raw_value_new(ptr: *mut raw::Value) -> Value {
|
|
|
|
|
Value::new(ptr)
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-16 02:05:44 +01:00
|
|
|
/// Borrow a reference to a [`Value`].
|
|
|
|
|
///
|
|
|
|
|
/// This calls `value_incref`, and the returned Value will call `value_decref` when dropped.
|
2025-12-15 19:48:30 -05:00
|
|
|
///
|
|
|
|
|
/// # Safety
|
|
|
|
|
///
|
2025-12-16 02:05:44 +01:00
|
|
|
/// The caller must ensure that the provided `ptr` has a positive reference count.
|
2025-04-02 18:49:03 +02:00
|
|
|
pub unsafe fn raw_value_new_borrowed(ptr: *mut raw::Value) -> Value {
|
|
|
|
|
Value::new_borrowed(ptr)
|
|
|
|
|
}
|