1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#[derive(Debug)] /// Pointer to a host allocated memory. pub struct Ptr(*mut std::ffi::c_void); impl Ptr { /// Get the inner ptr pub fn as_raw_ptr(&self) -> *mut std::ffi::c_void { self.0 } } impl<T> From<*mut T> for Ptr { fn from(ptr: *mut T) -> Self { Self(unsafe { std::mem::transmute(ptr) }) } } impl std::ops::Deref for Ptr { type Target = *mut std::ffi::c_void; fn deref(&self) -> &Self::Target { &self.0 } }