Skip to main content

Kernel

Trait Kernel 

Source
pub trait Kernel: Default + 'static {
    // Required method
    fn process(&mut self, cc: &mut KernelCtx<'_>) -> Result<()>;

    // Provided methods
    fn get_contract(_c: &mut KernelContract<'_>) { ... }
    fn open(&mut self, _cc: &mut KernelCtx<'_>) -> Result<()> { ... }
    fn close(&mut self, _cc: &mut KernelCtx<'_>) -> Result<()> { ... }
}
Expand description

The interface for writing a kernel in Rust.

Default is how the engine constructs an instance (T::default() at create time); real initialisation — reading node options, allocating long-lived state — belongs in open. Only process is required.

Required Methods§

Source

fn process(&mut self, cc: &mut KernelCtx<'_>) -> Result<()>

Called on every activation: read the inputs, produce output. Required.

Provided Methods§

Source

fn get_contract(_c: &mut KernelContract<'_>)

Declare port types and required side packets. Optional: declaring nothing means every port accepts any payload type.

Source

fn open(&mut self, _cc: &mut KernelCtx<'_>) -> Result<()>

Called once when the graph starts: read options, allocate long-lived state.

Source

fn close(&mut self, _cc: &mut KernelCtx<'_>) -> Result<()>

Called once when the stream closes: flush, release, finalise.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§