Skip to main content

Kiln

Struct Kiln 

Source
pub struct Kiln { /* private fields */ }
Expand description

The kiln — the runtime that fires tasks and cools them to detect patterns.

Like a pottery kiln, this runtime has two distinct phases:

  1. Firing: Tasks execute (fire()), producing outputs and metrics. This is the hot phase — the work gets done.

  2. Cooling: After all tasks have fired, the runtime examines the completed tasks for emergent patterns. The crackle glaze forms in the cooling, not the firing.

§Example

use crackle_runtime::{CrackleTask, Kiln, ThermalProfile, TaskOutput};

struct MyTask { x: f64 }
impl CrackleTask for MyTask {
    type Output = f64;
    fn fire(&self) -> TaskOutput<Self::Output> {
        TaskOutput::new(self.x, vec![("value".into(), self.x)])
    }
}

let mut kiln = Kiln::new(ThermalProfile::default());
kiln.fire_task(MyTask { x: 1.0 });
kiln.fire_task(MyTask { x: 2.0 });
kiln.fire_task(MyTask { x: 3.0 });

let patterns = kiln.cool();

Implementations§

Source§

impl Kiln

Source

pub fn new(profile: ThermalProfile) -> Self

Create a new kiln with the given thermal profile.

Source

pub fn default_profile() -> Self

Create a kiln with default thermal profile.

Source

pub fn fire_task<T: CrackleTask>(&self, task: T) -> TaskOutput<T::Output>

Fire a single task and record its output.

Returns the task’s output value.

§Panics

Panics if called after cool().

Source

pub fn fire_and_record<T: CrackleTask>( &mut self, task: T, ) -> TaskOutput<T::Output>

Fire a task and record it in the kiln for later cooling.

This stores the task’s metrics internally so patterns can be detected during the cooling phase.

Source

pub fn fire_all<T: CrackleTask>( &mut self, tasks: Vec<T>, ) -> Vec<TaskOutput<T::Output>>

Fire multiple tasks in sequence and record them all.

Source

pub fn add_entry( &mut self, label: impl Into<String>, metrics: Vec<(String, f64)>, )

Add a pre-computed task entry directly (useful for testing).

Source

pub fn task_count(&self) -> usize

The number of tasks currently in the kiln.

Source

pub fn entries(&self) -> &[TaskEntry]

Get all task entries.

Source

pub fn cool(&mut self) -> Vec<CracklePattern>

Cool the kiln: run pattern detection across all completed tasks.

This is where the beauty emerges. Just as a pottery kiln’s crackle glaze forms during cooling, the patterns that crackle-runtime detects are only visible after the heat of execution has passed.

Returns all detected patterns.

Source

pub fn is_cooled(&self) -> bool

Check if the kiln has been cooled.

Source

pub fn profile(&self) -> &ThermalProfile

Get the thermal profile.

Source

pub fn reset(&mut self)

Reset the kiln for a new firing cycle.

Auto Trait Implementations§

§

impl Freeze for Kiln

§

impl RefUnwindSafe for Kiln

§

impl Send for Kiln

§

impl Sync for Kiln

§

impl Unpin for Kiln

§

impl UnsafeUnpin for Kiln

§

impl UnwindSafe for Kiln

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.