pub trait CuSinkTask: Freezable + Reflect {
type Input<'m>: CuMsgPack;
type Resources<'r>;
// Required methods
fn new(
_config: Option<&ComponentConfig>,
_resources: Self::Resources<'_>,
) -> Result<Self, CuError>
where Self: Sized;
fn process<'i>(
&mut self,
_ctx: &CuContext,
input: &Self::Input<'i>,
) -> Result<(), CuError>;
// Provided methods
fn register_debug_state_types(registry: &mut TypeRegistry)
where Self: Sized + GetTypeRegistration { ... }
fn debug_state_type_path() -> &'static str
where Self: Sized + TypePath { ... }
fn with_debug_state<R>(
&self,
f: impl FnOnce(&(dyn Reflect + 'static)) -> R,
) -> R
where Self: Sized { ... }
fn start(&mut self, _ctx: &CuContext) -> Result<(), CuError> { ... }
fn preprocess(&mut self, _ctx: &CuContext) -> Result<(), CuError> { ... }
fn postprocess(&mut self, _ctx: &CuContext) -> Result<(), CuError> { ... }
fn stop(&mut self, _ctx: &CuContext) -> Result<(), CuError> { ... }
}Expand description
A Sink Task is a task that only consumes messages. For example drivers for actuators are Sink Tasks.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn register_debug_state_types(registry: &mut TypeRegistry)where
Self: Sized + GetTypeRegistration,
fn register_debug_state_types(registry: &mut TypeRegistry)where
Self: Sized + GetTypeRegistration,
Registers the reflected type used as this task’s debug-state contract.
The default exposes the task struct itself. Override this when the task contains ignored, third-party, hardware, or otherwise non-inspectable internals and should expose a purpose-built debug-state view instead.
Sourcefn debug_state_type_path() -> &'static str
fn debug_state_type_path() -> &'static str
Returns the reflected type path used as this task’s debug-state schema.
Sourcefn with_debug_state<R>(
&self,
f: impl FnOnce(&(dyn Reflect + 'static)) -> R,
) -> Rwhere
Self: Sized,
fn with_debug_state<R>(
&self,
f: impl FnOnce(&(dyn Reflect + 'static)) -> R,
) -> Rwhere
Self: Sized,
Borrows this task’s current debug-state view.
Override this together with debug_state_type_path
when the debug state is a projected view rather than the task struct.
Sourcefn start(&mut self, _ctx: &CuContext) -> Result<(), CuError>
fn start(&mut self, _ctx: &CuContext) -> Result<(), CuError>
Start is called between the creation of the task and the first call to pre/process.
Sourcefn preprocess(&mut self, _ctx: &CuContext) -> Result<(), CuError>
fn preprocess(&mut self, _ctx: &CuContext) -> Result<(), CuError>
This is a method called by the runtime before “process”. This is a kind of best effort, as soon as possible call to give a chance for the task to do some work before to prepare to make “process” as short as possible.
Sourcefn postprocess(&mut self, _ctx: &CuContext) -> Result<(), CuError>
fn postprocess(&mut self, _ctx: &CuContext) -> Result<(), CuError>
This is a method called by the runtime after “process”. It is best effort a chance for the task to update some state after process is out of the way. It can be use for example to maintain statistics etc. that are not time-critical for the robot.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".