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::Observation;
use super::Glass;

/// Clear glass. Payload guaranteed. Passthrough.
///
/// Types implementing GlassStable are making a compile-time
/// promise: there IS a value here. Not Option. Not maybe.
/// The transition succeeded fully.
pub trait GlassStable<GLASS>: Glass<GLASS>
where
	Self: Sized,
{
	/// Guaranteed value extraction. Not Option.
	/// This is the Stable contract.
	fn value(&self) -> Observation<&GLASS>;

	/// Consume and extract. Guaranteed.
	fn into_value(self) -> Observation<GLASS>
	where
		Self: Sized;
}

/// Annotation on a Stable observation.
/// "Everything's fine, and also here's something you should know."
pub trait StableAnnotation<GLASS>: GlassStable<GLASS>
where
	Self: Sized,
	GLASS: for<'str> Glass<&'str str>
{
	fn annotation(&self) -> &GLASS;

	/// Stable annotations can optionally suggest a better path
	/// even though the current one succeeded.
	fn alternative(&self) -> Option<&GLASS> { None }
}