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 pub fn as_ptr(&self) -> *mut c_void {
23 self.0
24 }
25}
26
27foreign_type_and_impl_send_sync! {
28 type CType = ffi::CONF;
29 fn drop = ffi::NCONF_free;
30
31 pub struct Conf;
32}
33
34impl Conf {
35 pub fn new(method: ConfMethod) -> Result<Conf, ErrorStack> {
37 unsafe { cvt_p(ffi::NCONF_new(method.as_ptr())).map(|p| Conf::from_ptr(p)) }
38 }
39}