Skip to main content

CuStatelessTask

Trait CuStatelessTask 

Source
pub trait CuStatelessTask:
    Reflect
    + Send
    + Sync {
    type Input<'m>: CuMsgPack;
    type Output<'m>: CuMsgPayload;
    type Resources<'r>;

    // Required methods
    fn new(
        _config: Option<&ComponentConfig>,
        _resources: Self::Resources<'_>,
    ) -> Result<Self, CuError>
       where Self: Sized;
    fn process<'i, 'o>(
        &self,
        _ctx: &CuContext,
        input: &Self::Input<'i>,
        output: &mut Self::Output<'o>,
    ) -> 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(&self, _ctx: &CuContext) -> Result<(), CuError> { ... }
    fn postprocess(&self, _ctx: &CuContext) -> Result<(), CuError> { ... }
    fn stop(&mut self, _ctx: &CuContext) -> Result<(), CuError> { ... }
}
Expand description

A transform task whose per-CopperList callbacks do not mutate the task instance.

Stateless tasks have the same input/output shape as CuTask, but preprocess, process, and postprocess receive &self. This makes the task safe for runtimes to invoke for different CopperLists concurrently. Construction, start, and stop remain exclusive lifecycle operations.

Stateless tasks do not require Freezable. The runtime records an empty keyframe component for them and leaves the task instance unchanged on restore.

Implementations must be Send and Sync. Any shared state reachable through self must preserve deterministic behavior when callbacks overlap.

Required Associated Types§

Source

type Input<'m>: CuMsgPack

Source

type Output<'m>: CuMsgPayload

Source

type Resources<'r>

Resources required by the task.

Required Methods§

Source

fn new( _config: Option<&ComponentConfig>, _resources: Self::Resources<'_>, ) -> Result<Self, CuError>
where Self: Sized,

Creates the task and binds its resources.

Source

fn process<'i, 'o>( &self, _ctx: &CuContext, input: &Self::Input<'i>, output: &mut Self::Output<'o>, ) -> Result<(), CuError>

Produces one output from the current CopperList inputs.

Provided Methods§

Source

fn register_debug_state_types(registry: &mut TypeRegistry)
where Self: Sized + GetTypeRegistration,

Registers the reflected type used as this task’s debug-state contract.

Source

fn debug_state_type_path() -> &'static str
where Self: Sized + TypePath,

Returns the reflected type path used as this task’s debug-state schema.

Source

fn with_debug_state<R>( &self, f: impl FnOnce(&(dyn Reflect + 'static)) -> R, ) -> R
where Self: Sized,

Borrows this task’s current debug-state view.

Source

fn start(&mut self, _ctx: &CuContext) -> Result<(), CuError>

Starts the task before its first per-CopperList callback.

Source

fn preprocess(&self, _ctx: &CuContext) -> Result<(), CuError>

Performs best-effort preparation for one CopperList.

Source

fn postprocess(&self, _ctx: &CuContext) -> Result<(), CuError>

Performs best-effort follow-up work for one CopperList.

Source

fn stop(&mut self, _ctx: &CuContext) -> Result<(), CuError>

Stops the task after all per-CopperList callbacks have completed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§