1 use crate::cvt_p; 2 use crate::error::ErrorStack; 3 use foreign_types::ForeignType; 4 use openssl_macros::corresponds; 5 6 foreign_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 14 impl LibCtx { 15 #[corresponds(OSSL_LIB_CTX_new)] new() -> Result<Self, ErrorStack>16 pub fn new() -> Result<Self, ErrorStack> { 17 unsafe { 18 let ptr = cvt_p(ffi::OSSL_LIB_CTX_new())?; 19 Ok(LibCtx::from_ptr(ptr)) 20 } 21 } 22 } 23