Compare commits
2 commits
0ba06d0f2c
...
5e1600277c
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e1600277c | |||
| 8b78930472 |
7 changed files with 24 additions and 42 deletions
24
TODO.md
24
TODO.md
|
|
@ -1,24 +0,0 @@
|
|||
- [ ] rename `AsInnerPtr::as_ptr` to `AsInnerPtr::as_mut_ptr`
|
||||
|
||||
- [ ] add NixError::from_nonnull that replaces calls to NonNull::new(...).ok_or(...)
|
||||
- [ ] replace all `use nixide_sys as sys;` -> `use crate::sys;`
|
||||
- [ ] store NonNull pointers in structs!
|
||||
- [ ] improve documentation situation on context.rs
|
||||
|
||||
- [ ] rename `as_ptr()` to `as_inner_ptr()` or `inner_ptr()`?
|
||||
- [ ] ^^^ this fn should be added to a trait (maybe just `trait NixStructWrapper : AsPtr { ... }`)
|
||||
- [ ] ^^^ also make `as_ptr()` public
|
||||
|
||||
- [ ] add mutexs and make the library thread safe!!
|
||||
|
||||
- [ ] grep all `self.inner.as_ptr()` calls and replace them with `self.as_ptr()`
|
||||
|
||||
|
||||
- [ ] `ErrorContext::peak` should return `Result<(), NixideError>` **not** `Option<NixideError>`
|
||||
- [ ] `self.expect_type` should instead be a macro to preserve the trace macro location
|
||||
|
||||
- [ ] make `Value` an enum instead because like duhh
|
||||
|
||||
- [ ] ensure we're always calling `ctx.peak()` unless it's ACTUALLY not necessary
|
||||
|
||||
- [ ] replace *most* calls to `ErrorContext::peak()` with `ErrorContext::pop()`
|
||||
|
|
@ -182,8 +182,6 @@ impl ErrorContext {
|
|||
/// of `nix_c_context` must be careful to check the `last_err_code` regularly.
|
||||
pub fn clear(&mut self) {
|
||||
unsafe {
|
||||
// NOTE: previous nixops4 used the line: (maybe for compatability with old versions?)
|
||||
// sys::nix_set_err_msg(self.inner.as_ptr(), sys::nix_err_NIX_OK, c"".as_ptr());
|
||||
sys::nix_clear_err(self.as_ptr());
|
||||
}
|
||||
}
|
||||
|
|
@ -351,7 +349,7 @@ impl ErrorContext {
|
|||
impl Drop for ErrorContext {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
sys::nix_c_context_free(self.inner.as_ptr());
|
||||
sys::nix_c_context_free(self.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,9 +97,8 @@ impl EvalState {
|
|||
|
||||
impl Drop for EvalState {
|
||||
fn drop(&mut self) {
|
||||
// SAFETY: We own the state and it's valid until drop
|
||||
unsafe {
|
||||
sys::nix_state_free(self.inner.as_ptr());
|
||||
sys::nix_state_free(self.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,9 +77,8 @@ impl EvalStateBuilder {
|
|||
|
||||
impl Drop for EvalStateBuilder {
|
||||
fn drop(&mut self) {
|
||||
// SAFETY: We own the builder and it's valid until drop
|
||||
unsafe {
|
||||
sys::nix_eval_state_builder_free(self.inner.as_ptr());
|
||||
sys::nix_eval_state_builder_free(self.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ use std::result::Result;
|
|||
|
||||
use crate::errors::{new_nixide_error, ErrorContext};
|
||||
use crate::stdext::CCharPtrExt;
|
||||
use crate::sys;
|
||||
use crate::util::wrap;
|
||||
use crate::util::wrappers::AsInnerPtr;
|
||||
use crate::{NixideError, NixideResult};
|
||||
use nixide_sys as sys;
|
||||
|
||||
/// Nix store for managing packages and derivations.
|
||||
///
|
||||
|
|
@ -129,7 +129,7 @@ impl Store {
|
|||
|
||||
sys::nix_store_realise(
|
||||
ctx.as_ptr(),
|
||||
self.inner.as_ptr(),
|
||||
self.as_ptr(),
|
||||
path.as_ptr(),
|
||||
(*state).inner_ptr() as *mut c_void,
|
||||
Some(callback),
|
||||
|
|
@ -173,7 +173,7 @@ impl Store {
|
|||
|callback, userdata: *mut __UserData, ctx: &ErrorContext| unsafe {
|
||||
sys::nix_store_get_version(
|
||||
ctx.as_ptr(),
|
||||
self.inner.as_ptr(),
|
||||
self.as_ptr(),
|
||||
Some(callback),
|
||||
userdata as *mut c_void,
|
||||
)
|
||||
|
|
@ -187,7 +187,7 @@ impl Store {
|
|||
|callback, userdata: *mut __UserData, ctx: &ErrorContext| unsafe {
|
||||
sys::nix_store_get_uri(
|
||||
ctx.as_ptr(),
|
||||
self.inner.as_ptr(),
|
||||
self.as_ptr(),
|
||||
Some(callback),
|
||||
userdata as *mut c_void,
|
||||
)
|
||||
|
|
@ -200,7 +200,7 @@ impl Store {
|
|||
|callback, userdata: *mut __UserData, ctx: &ErrorContext| unsafe {
|
||||
sys::nix_store_get_storedir(
|
||||
ctx.as_ptr(),
|
||||
self.inner.as_ptr(),
|
||||
self.as_ptr(),
|
||||
Some(callback),
|
||||
userdata as *mut c_void,
|
||||
)
|
||||
|
|
@ -242,7 +242,7 @@ impl Store {
|
|||
impl Drop for Store {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
sys::nix_store_free(self.inner.as_ptr());
|
||||
sys::nix_store_free(self.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,12 @@ use std::ptr::NonNull;
|
|||
|
||||
use super::Store;
|
||||
use crate::errors::{new_nixide_error, ErrorContext};
|
||||
use crate::sys;
|
||||
use crate::util::panic_issue_call_failed;
|
||||
use crate::util::wrap;
|
||||
use crate::util::wrappers::AsInnerPtr;
|
||||
use crate::NixideResult;
|
||||
|
||||
use nixide_sys as sys;
|
||||
|
||||
/// A path in the Nix store.
|
||||
///
|
||||
/// Represents a store path that can be realized, queried, or manipulated.
|
||||
|
|
@ -20,9 +19,20 @@ pub struct StorePath {
|
|||
}
|
||||
|
||||
impl AsInnerPtr<sys::StorePath> for StorePath {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::StorePath {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::StorePath {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::StorePath {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
||||
impl StorePath {
|
||||
|
|
@ -61,7 +71,7 @@ impl StorePath {
|
|||
///
|
||||
pub fn name(&self) -> NixideResult<String> {
|
||||
wrap::nix_string_callback!(|callback, userdata: *mut __UserData, _| unsafe {
|
||||
sys::nix_store_path_name(self.inner.as_ptr(), Some(callback), userdata as *mut c_void);
|
||||
sys::nix_store_path_name(self.as_ptr(), Some(callback), userdata as *mut c_void);
|
||||
// NOTE: nix_store_path_name doesn't return nix_err, so we force it to return successfully
|
||||
// XXX: NOTE: now `nix_string_callback` is a macro this isn't necessary
|
||||
// sys::nix_err_NIX_OK
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ pub trait AsInnerPtr<T> {
|
|||
|
||||
/// Returns a shared reference to the inner `libnix` C struct.
|
||||
///
|
||||
/// For the mutable counterpart see [AsInnerPtr<T>::as_mut].
|
||||
/// For the mutable counterpart see [Self::as_mut].
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
|
|
@ -21,7 +21,7 @@ pub trait AsInnerPtr<T> {
|
|||
|
||||
/// Returns a unique reference to the inner `libnix` C struct.
|
||||
///
|
||||
/// For the shared counterpart see [AsInnerPtr<T>::as_ref].
|
||||
/// For the shared counterpart see [Self::as_ref].
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue