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>
impl<T: CrackleTask> GlazeLayer<T>
Sourcepub fn with_derived_metric(
self,
name: impl Into<String>,
compute: impl Fn(&TaskOutput<T::Output>) -> f64 + 'static,
) -> Self
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.
Sourcepub fn with_label(self, label: impl Into<String>) -> Self
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>
impl<T: CrackleTask> CrackleTask for GlazeLayer<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more