daemonic_error 1.0.0

Errors that compose, predict, and leave receipts - Compose: algebraic combination (in active development) - Predict: Glass/Severity - Receipts: audit trail, position, checksum - Reflection: Runtime Reflection through TopologySegment (in active development)
use crate::daemonic::glass::{Glass, Severity};
use crate::DaemonicError;

/// glass state changed during observation.
/// The observation is smeared across a fidelity transition.
/// Need both the starting and ending state to interpret.
pub trait GlassDrift<GLASS>: Glass<GLASS> + for<'error> DaemonicError<'error> {
	/// What severity did we start at?
	fn from_severity(&self) -> Severity;
	
	/// What severity did we end at?
	fn to_severity(&self) -> Severity;
	/// Drift states are sometimes retryable, as where other states are repairable.
	/// Drift basically boils down to: the Observation has drifted from where we thought it should be
	/// So this is set to false for Flow Control, call site definitions can set this to true in certain contexts so if ? returns a Drift state then retry logic can be passed through
	fn set_retry(&self) -> bool { false }
	/// For the sake of control flow, if retry is enabled and repair is defined at call site, then repair function will be passed instead of Breaking
	fn repair(&self) -> Option<&dyn Fn() -> GLASS> { None }
}
// Annotation on a Drift observation.
// "The glass changed during observation, here's the transition."
// annotation deprecated in favor on struct annotations
// pub trait DriftAnnotation<GLASS>: GlassDrift<GLASS> {
// 	fn annotation(&self) -> &str;
//
// 	/// What triggered the state change mid-observation?
// 	fn drift_trigger(&self) -> Option<&str> { None }
// }