zephyr::object

Enum Fixed

source
pub enum Fixed<T> {
    Static(*mut T),
    Owned(Pin<Box<UnsafeCell<T>>>),
}
Expand description

Objects that can be fixed or allocated.

When using Rust threads from userspace, the kobj_define declarations and the complexity behind it is required. If all Rust use of kernel objects is from system threads, and dynamic memory is available, kernel objects can be freeallocated, as long as the allocations themselves are pinned. This Fixed encapsulates both of these.

Variants§

§

Static(*mut T)

Objects that have been statically declared and just pointed to.

§

Owned(Pin<Box<UnsafeCell<T>>>)

Objects that are owned by the wrapper, and contained here.

Implementations§

source§

impl<T> Fixed<T>

source

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

Get the raw pointer out of the fixed object.

Returns the *mut T pointer held by this object. It is either just the static pointer, or the pointer outside of the unsafe cell holding the dynamic kernel object.

source

pub fn new(item: T) -> Fixed<T>

Construct a new fixed from an allocation. Note that the object will not be fixed in memory, until after this returns, and it should not be initialized until then.

Auto Trait Implementations§

§

impl<T> Freeze for Fixed<T>

§

impl<T> !RefUnwindSafe for Fixed<T>

§

impl<T> !Send for Fixed<T>

§

impl<T> !Sync for Fixed<T>

§

impl<T> Unpin for Fixed<T>

§

impl<T> UnwindSafe for Fixed<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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, U> Into<U> for T
where 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, U> TryFrom<U> for T
where U: Into<T>,

source§

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 T
where U: TryFrom<T>,

source§

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.