#[repr(transparent)]pub struct Opaque<T>(_);
Expand description
Stores an opaque value.
This is meant to be used with FFI objects that are never interpreted by Rust code.
Implementations
sourceimpl<T> Opaque<T>
impl<T> Opaque<T>
sourcepub fn ffi_init(init_func: impl FnOnce(*mut T)) -> impl PinInit<Self>
pub fn ffi_init(init_func: impl FnOnce(*mut T)) -> impl PinInit<Self>
Creates a pin-initializer from the given initializer closure.
The returned initializer calls the given closure with the pointer to the inner T
of this
Opaque
. Since this memory is uninitialized, the closure is not allowed to read from it.
This function is safe, because the T
inside of an Opaque
is allowed to be
uninitialized. Additionally, access to the inner T
requires unsafe
, so the caller needs
to verify at that point that the inner value is valid.
sourcepub const fn raw_get(this: *const Self) -> *mut T
pub const fn raw_get(this: *const Self) -> *mut T
Gets the value behind this
.
This function is useful to get access to the value without creating intermediate references.
Auto Trait Implementations
impl<T> !RefUnwindSafe for Opaque<T>
impl<T> Send for Opaque<T> where
T: Send,
impl<T> !Sync for Opaque<T>
impl<T> Unpin for Opaque<T> where
T: Unpin,
impl<T> UnwindSafe for Opaque<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more