pub struct CuContext {
pub clock: RobotClock,
/* private fields */
}Expand description
Execution context passed to task and bridge callbacks.
CuContext provides callback code with:
- time access through
clockandDeref<Target = RobotClock> - current execution sequence id via
cl_id() - current task metadata via
task_id()/task_index()
The execution sequence id matches the copper-list id of the iteration being
processed. It is also available in other lifecycle callbacks
(start/preprocess/postprocess/stop) for continuity, but outside
process callbacks it must not be treated as a live copper-list handle.
The runtime creates one context per execution loop and updates transient fields such as the currently executing task before each callback.
Fields§
§clock: RobotClockRuntime clock. Kept as a field for direct access (context.clock.now()).
Implementations§
Source§impl CuContext
impl CuContext
Sourcepub fn builder(clock: RobotClock) -> CuContextBuilder
pub fn builder(clock: RobotClock) -> CuContextBuilder
Starts a context builder from a clock.
Sourcepub fn from_clock(clock: RobotClock) -> Self
pub fn from_clock(clock: RobotClock) -> Self
Creates a context from an existing clock with default metadata.
Defaults:
cl_id = 0- no task id table
Sourcepub fn new_with_clock() -> Self
pub fn new_with_clock() -> Self
Creates a context backed by a real robot clock.
Defaults:
cl_id = 0- no task id table
Sourcepub fn new_mock_clock() -> (Self, RobotClockMock)
pub fn new_mock_clock() -> (Self, RobotClockMock)
Creates a context backed by a mock clock.
Returns both the context and its [RobotClockMock] control handle.
Sourcepub fn set_current_task(&mut self, task_index: usize)
pub fn set_current_task(&mut self, task_index: usize)
Sets the currently executing task index.
Sourcepub fn clear_current_task(&mut self)
pub fn clear_current_task(&mut self)
Clears the currently executing task.
Sourcepub fn cl_id(&self) -> u64
pub fn cl_id(&self) -> u64
Returns the current execution sequence id.
In process callbacks, this value is the id of the copper-list being
processed. In other lifecycle callbacks, this value is still meaningful
for sequencing but does not imply that a copper-list instance is alive.
Sourcepub fn task_index(&self) -> Option<usize>
pub fn task_index(&self) -> Option<usize>
Returns the current task index, if any.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CuContext
impl RefUnwindSafe for CuContext
impl Send for CuContext
impl Sync for CuContext
impl Unpin for CuContext
impl UnsafeUnpin for CuContext
impl UnwindSafe for CuContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more