#[repr(transparent)]pub struct Opaque<T> { /* private fields */ }
Expand description
Stores an opaque value.
This is meant to be used with FFI objects that are never interpreted by Rust code.
Implementations§
source§impl<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.
Trait Implementations§
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>
impl<T> UnwindSafe for Opaque<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more