madsim_rdkafka

Trait IntoOpaque

Source
pub trait IntoOpaque:
    Send
    + Sync
    + Sized {
    // Required methods
    fn into_ptr(self) -> *mut c_void;
    unsafe fn from_ptr(_: *mut c_void) -> Self;
}
Expand description

Converts Rust data to and from raw pointers.

This conversion is used to pass opaque objects to the C library and vice versa.

Required Methods§

Source

fn into_ptr(self) -> *mut c_void

Converts the object into a raw pointer.

Source

unsafe fn from_ptr(_: *mut c_void) -> Self

Converts the raw pointer back to the original Rust object.

§Safety

The pointer must be created with into_ptr.

Care must be taken to not call more than once if it would result in an aliasing violation (e.g. Box).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl IntoOpaque for ()

Source§

fn into_ptr(self) -> *mut c_void

Source§

unsafe fn from_ptr(_: *mut c_void) -> Self

Source§

impl IntoOpaque for usize

Source§

fn into_ptr(self) -> *mut c_void

Source§

unsafe fn from_ptr(ptr: *mut c_void) -> Self

Source§

impl<T: Send + Sync> IntoOpaque for Box<T>

Source§

fn into_ptr(self) -> *mut c_void

Source§

unsafe fn from_ptr(ptr: *mut c_void) -> Self

Source§

impl<T: Send + Sync> IntoOpaque for Arc<T>

Source§

fn into_ptr(self) -> *mut c_void

Source§

unsafe fn from_ptr(ptr: *mut c_void) -> Self

Implementors§