pub struct Cell<T> { /* private fields */ }
Implementations§
Source§impl<T> Cell<T>
impl<T> Cell<T>
pub const fn new() -> Self
pub const fn new_with(init: T) -> Self
pub fn is_initialized(&self) -> bool
pub fn ref_num(&self) -> Result<usize, MemoryState>
Sourcepub fn try_take(&self) -> Result<Option<T>, Error<()>>
pub fn try_take(&self) -> Result<Option<T>, Error<()>>
Takes ownership of the current value, leaving the cell uninitialized.
Returns Err if the cell is refered or in critical section.
Sourcepub fn take(&self) -> Result<Option<T>, Error<()>>
pub fn take(&self) -> Result<Option<T>, Error<()>>
Takes ownership of the current value, leaving the cell uninitialized.
Returns Err is unreachable.
Notice: Spin
pub unsafe fn peek(&self) -> &T
Sourcepub fn try_get(&self) -> Result<Ref<'_, T>, Error<()>>
pub fn try_get(&self) -> Result<Ref<'_, T>, Error<()>>
Tries to get a reference to the value of the Cell.
Returns Err if the cell is uninitialized, in operation or in critical section.
Sourcepub fn get(&self) -> Result<Ref<'_, T>, Error<()>>
pub fn get(&self) -> Result<Ref<'_, T>, Error<()>>
Tries to get a reference to the value of the Cell.
Returns Err if the cell is uninitialized.
Notice: Spin
Sourcepub fn try_set(&self, value: T) -> Result<(), Error<T>>
pub fn try_set(&self, value: T) -> Result<(), Error<T>>
Sets the value of the Cell to the argument value.
Returns Err if the value is refered, initialized or in critical section.
Sourcepub fn set(&self, value: T) -> Result<(), Error<T>>
pub fn set(&self, value: T) -> Result<(), Error<T>>
Sets the value of the Cell to the argument value.
Returns Err if the value is refered, initialized.
Notice: Spin
Sourcepub fn try_replace(&self, value: T) -> Result<Option<T>, Error<T>>
pub fn try_replace(&self, value: T) -> Result<Option<T>, Error<T>>
Replaces the contained value with value, and returns the old contained value.
Returns Err if the value is refered or in critical section.
Sourcepub fn replace(&self, value: T) -> Result<Option<T>, Error<T>>
pub fn replace(&self, value: T) -> Result<Option<T>, Error<T>>
Replaces the contained value with value, and returns the old contained value.
Returns Err is unreachable.
Notice: Spin
Sourcepub fn get_or_try_init(&self, value: T) -> Result<Ref<'_, T>, Error<T>>
pub fn get_or_try_init(&self, value: T) -> Result<Ref<'_, T>, Error<T>>
Tries to get a reference to the value of the Cell.
Returns Err if the cell is in critical section.
Sourcepub fn get_or_init(&self, value: T) -> Ref<'_, T>
pub fn get_or_init(&self, value: T) -> Ref<'_, T>
Tries to get a reference to the value of the Cell.
Notice: Spin