Struct kernel::types::Opaque

source ·
#[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>

source

pub const fn new(value: T) -> Self

Creates a new opaque value.

source

pub const fn uninit() -> Self

Creates an uninitialised value.

source

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.

source

pub fn get(&self) -> *mut T

Returns a raw pointer to the opaque data.

source

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§

source§

impl<T> Zeroable for Opaque<T>

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, E> Init<T, E> for T

source§

unsafe fn __init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, E> PinInit<T, E> for T

source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
This documentation is an old archive. Please see https://rust.docs.kernel.org instead.