daemonic_error 0.1.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;
use crate::DaemonicError;

/// Information lost. Structure holds but data is incomplete.
/// Unlike Cracked, Fracture CAN cascade.
pub trait GlassFracture<GLASS>: Glass<GLASS> + for<'error> DaemonicError<'error> {
	/// What was lost? Human-readable description.
	fn loss_description(&self) -> &str;

	/// How much of the original survived? 0.0 to 1.0
	fn salvage_ratio(&self) -> f64 {
		match self.payload() {
			Some(_) => 0.5, // something survived, rough default
			None => 0.0,
		}
	}

	/// Attempt repair. Same pattern as Cracked but for
	/// information reconstruction, not containment.
	fn repair(&self) -> Option<&dyn Fn() -> Option<GLASS>> {
		None
	}
}
/// Annotation on a Fracture observation.
/// "Information was lost, here's what and here's how to maybe get it back."
pub trait FractureAnnotation<GLASS>: GlassFracture<GLASS> {
	fn annotation(&self) -> &str;

	/// What specific information was lost?
	fn loss_detail(&self) -> &str;

	/// Suggested recovery strategy, if any.
	fn recovery_strategy(&self) -> Option<&str> { None }
}