Rename crates nix- -> nix-bindings-
This way, the crates can be published without interfering with potential future non-bindings `nix-` crates, if Nix proper wants to have native rust code, for instance.
This commit is contained in:
parent
4b13929db3
commit
b3171585d1
30 changed files with 209 additions and 1853 deletions
38
rust/nix-bindings-fetchers/src/lib.rs
Normal file
38
rust/nix-bindings-fetchers/src/lib.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
use anyhow::{Context as _, Result};
|
||||
use nix_bindings_bindgen_raw as raw;
|
||||
use nix_bindings_util::context::{self, Context};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
pub struct FetchersSettings {
|
||||
pub(crate) ptr: NonNull<raw::fetchers_settings>,
|
||||
}
|
||||
impl Drop for FetchersSettings {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
raw::fetchers_settings_free(self.ptr.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
impl FetchersSettings {
|
||||
pub fn new() -> Result<Self> {
|
||||
let mut ctx = Context::new();
|
||||
let ptr = unsafe { context::check_call!(raw::fetchers_settings_new(&mut ctx))? };
|
||||
Ok(FetchersSettings {
|
||||
ptr: NonNull::new(ptr).context("fetchers_settings_new unexpectedly returned null")?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn raw_ptr(&self) -> *mut raw::fetchers_settings {
|
||||
self.ptr.as_ptr()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn fetchers_settings_new() {
|
||||
let _ = FetchersSettings::new().unwrap();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue