nixide/nix-bindings-fetchers/src/lib.rs
John Ericson dbb00333b1 Split monolithic raw crates into sys crates
Creating a crate for bwd-gc highlights the fact that it would be nice to
fix 2!

The file blocklist is a lost less unmaintainable then the more
fine-grained one we had before.

Fix #9
2026-01-12 19:48:45 -05:00

38 lines
958 B
Rust

use anyhow::{Context as _, Result};
use nix_bindings_fetchers_sys 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();
}
}