use std::marker::PhantomData; use opaque::Opaque; pub unsafe trait OpenSslType { type CType; unsafe fn from_ptr(ptr: *mut Self::CType) -> Self; fn as_ptr(&self) -> *mut Self::CType; } pub struct Ref(Opaque, PhantomData); impl Ref { pub unsafe fn from_ptr<'a>(ptr: *mut T::CType) -> &'a Ref { &*(ptr as *mut _) } pub unsafe fn from_ptr_mut<'a>(ptr: *mut T::CType) -> &'a mut Ref { &mut *(ptr as *mut _) } pub fn as_ptr(&self) -> *mut T::CType { self as *const _ as *mut _ } }