Skip to main content

GlazeLayer

Struct GlazeLayer 

Source
pub struct GlazeLayer<T: CrackleTask> { /* private fields */ }
Expand description

A decorator that adds pattern-detection capability to any task.

In pottery, a glaze layer is applied to the surface of a vessel before firing. The glaze doesn’t change what the vessel is — it changes what it reveals. During cooling, the glaze crackles, making visible patterns that the plain clay would never show.

GlazeLayer wraps any task and enriches its metrics, making the underlying patterns more visible to the kiln’s pattern detectors.

§Example

use crackle_runtime::{CrackleTask, GlazeLayer, TaskOutput};

struct SimpleTask { value: f64 }
impl CrackleTask for SimpleTask {
    type Output = f64;
    fn fire(&self) -> TaskOutput<Self::Output> {
        TaskOutput::simple(self.value)
    }
}

let task = SimpleTask { value: 42.0 };
let glazed = GlazeLayer::new(task)
    .with_derived_metric("squared", |out| out.value * out.value)
    .with_derived_metric("log", |out| out.value.ln());

let output = glazed.fire();
assert!(output.metrics.len() >= 2);

Implementations§

Source§

impl<T: CrackleTask> GlazeLayer<T>

Source

pub fn new(task: T) -> Self

Create a new glaze layer wrapping the given task.

Source

pub fn with_derived_metric( self, name: impl Into<String>, compute: impl Fn(&TaskOutput<T::Output>) -> f64 + 'static, ) -> Self

Add a derived metric computed from the task output.

Derived metrics are computed after firing and added to the output’s metric list, giving pattern detectors more signal to work with.

Source

pub fn with_label(self, label: impl Into<String>) -> Self

Override the task’s label.

Trait Implementations§

Source§

impl<T: CrackleTask> CrackleTask for GlazeLayer<T>

Source§

type Output = <T as CrackleTask>::Output

The type of value produced by firing.
Source§

fn fire(&self) -> TaskOutput<Self::Output>

Execute the task (the hot phase). Read more
Source§

fn cool( &self, output: &TaskOutput<Self::Output>, all_metrics: &[(String, Vec<(String, f64)>)], ) -> Vec<(String, f64)>

Reflect on the task during cooling (optional). Read more
Source§

fn label(&self) -> String

A human-readable label for this task (used in pattern descriptions).

Auto Trait Implementations§

§

impl<T> Freeze for GlazeLayer<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for GlazeLayer<T>

§

impl<T> !Send for GlazeLayer<T>

§

impl<T> !Sync for GlazeLayer<T>

§

impl<T> Unpin for GlazeLayer<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for GlazeLayer<T>
where T: UnsafeUnpin,

§

impl<T> !UnwindSafe for GlazeLayer<T>

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.