1use crate::ffi;
3use foreign_types::ForeignType;
4use libc::c_void;
5
6use crate::cvt_p;
7use crate::error::ErrorStack;
8
9pub struct ConfMethod(*mut c_void);
10
11impl ConfMethod {
12 pub unsafe fn from_ptr(ptr: *mut c_void) -> ConfMethod {
18 ConfMethod(ptr)
19 }
20
21 #[must_use]
23 pub fn as_ptr(&self) -> *mut c_void {
24 self.0
25 }
26}
27
28foreign_type_and_impl_send_sync! {
29 type CType = ffi::CONF;
30 fn drop = ffi::NCONF_free;
31
32 pub struct Conf;
33}
34
35impl Conf {
36 pub fn new(method: ConfMethod) -> Result<Conf, ErrorStack> {
38 unsafe { cvt_p(ffi::NCONF_new(method.as_ptr())).map(|p| Conf::from_ptr(p)) }
39 }
40}