[−][src]Struct cmim::Move
Move is a structure that is intended to be stored as a static variable,
and represents a metaphorical "move" to an interrupt context. Data is moved
to the interrupt context by calling try_move
from thread (non-interrupt)
context, and the data can be retrived within a selected interrupt using the
try_lock
method.
Methods
impl<T, I> Move<T, I>
[src]
pub const fn new_uninitialized(inter: I) -> Self
[src]
Create a new Move
structure without initializing the data contained by it.
This is best used when the data cannot be initialized until runtime, such as
a HAL peripheral, or the producer or consumer of a queue.
Before using this in interrupt context, you must initialize it with the
try_move
function, or it will return errors upon access.
You must provide the interrupt that is allowed to later access this data
as the inter
argument
pub const fn new(data: T, inter: I) -> Self
[src]
Create a new Move
structure, and initialize the data contained within it.
This is best used when the data contained within is const
, and doesn't require
runtime initialization.
This does not require further interaction before use in interrupt context.
You must provide the interrupt that is allowed to later access this data
as the inter
argument
impl<T, I> Move<T, I> where
T: Send + Sized,
I: Nr,
[src]
T: Send + Sized,
I: Nr,
pub fn try_move(&self, data: T) -> Result<Option<T>, T>
[src]
Attempt to initialize the data of the Move
structure.
This MUST be called from non-interrupt context, and a critical
section will be in place while setting the data.
Returns:
- Ok(Some(T)): If we are in thread mode and the data was previously initialized
- Ok(None): If we are in thread mode and the data was not previously initialized
- Err(T): If we are not in thread mode (e.g. an interrupt is active), return the data that was going to be moved
pub fn try_free(&self) -> Result<Option<T>, ()>
[src]
Attempt to recover the data from the Move
structure.
This MUST be called from non-interrupt context, and a critical
section will be in place while receiving the data.
Returns:
- Ok(Some(T)): If we are in thread mode and the data was previously initialized
- Ok(None): If we are in thread mode and the data was not previously initialized
- Err(()): If we are not in thread mode (e.g. an interrupt is active)
pub fn try_lock<R>(&self, f: impl FnOnce(&mut T) -> R) -> Result<R, ()>
[src]
So, this isn't a classical mutex. It will only provide access if:
- The selected interrupt is currently active
- The mutex has not already been locked
If these conditions are met, then you can access the variable from within a closure
Trait Implementations
Auto Trait Implementations
impl<T, I> Send for Move<T, I> where
I: Send,
T: Send,
I: Send,
T: Send,
impl<T, I> Unpin for Move<T, I> where
I: Unpin,
T: Unpin,
I: Unpin,
T: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,