1use crate::cvt_p;
2use crate::error::ErrorStack;
3use foreign_types::ForeignType;
4use openssl_macros::corresponds;
5
6foreign_type_and_impl_send_sync! {
7 type CType = ffi::OSSL_LIB_CTX;
8 fn drop = ffi::OSSL_LIB_CTX_free;
9
10 pub struct LibCtx;
11 pub struct LibCtxRef;
12}
13
14impl LibCtx {
15 #[corresponds(OSSL_LIB_CTX_new)]
16 pub fn new() -> Result<Self, ErrorStack> {
17 unsafe {
18 let ptr: *mut OSSL_LIB_CTX = cvt_p(ffi::OSSL_LIB_CTX_new())?;
19 Ok(LibCtx::from_ptr(ptr))
20 }
21 }
22}
23