Skip to main content

LocalItem

Struct LocalItem 

Source
pub struct LocalItem<T> { /* private fields */ }
Expand description

A scope-local item.

Implementations§

Source§

impl<T: Send + Sync + 'static> LocalItem<T>

Source

pub fn with<R>(&self, operation: impl for<'access> FnOnce(&'access T) -> R) -> R

Runs operation with the value selected by the active scope.

The higher-ranked closure prevents a reference into per-CPU-selected storage from escaping after preemption is re-enabled. The first global access initializes the global scope before entering the pinned access. Concurrent first access waits for that initialization to be published.

Source

pub fn with_pinned<R>( &self, pin: &CpuPin<'_>, operation: impl for<'access> FnOnce(&'access T) -> R, ) -> R

Runs operation under an existing CPU pin without initialization.

§Panics

Panics if the selected global scope has not been initialized by LocalItem::with. Explicit Scope values are initialized eagerly.

Source

pub fn try_with_pinned<R>( &self, pin: &CpuPin<'_>, operation: impl for<'access> FnOnce(&'access T) -> R, ) -> Option<R>

Runs operation without lazy initialization under an existing pin.

This returns None when the selected global scope has not yet been initialized, allowing hard-IRQ callers to avoid allocation.

Source

pub fn clone_current(&self) -> T
where T: Clone,

Clones the selected value while keeping the CPU pin lifetime short.

Source

pub fn scope<'scope>(&self, scope: &'scope Scope) -> ScopeItem<'scope, T>

Returns a reference to this item within the given scope.

Source

pub fn scope_mut<'scope>( &self, scope: &'scope mut Scope, ) -> ScopeItemMut<'scope, T>

Returns a mutable reference to this item within the given scope.

Auto Trait Implementations§

§

impl<T> Freeze for LocalItem<T>

§

impl<T> RefUnwindSafe for LocalItem<T>
where T: RefUnwindSafe,

§

impl<T> Send for LocalItem<T>
where T: Send,

§

impl<T> Sync for LocalItem<T>
where T: Sync,

§

impl<T> Unpin for LocalItem<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for LocalItem<T>

§

impl<T> UnwindSafe for LocalItem<T>
where T: UnwindSafe,

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.