pub enum Cause<E> {
Fail(E),
Die(String),
Interrupt(FiberId),
Both(Box<Cause<E>>, Box<Cause<E>>),
Then(Box<Cause<E>>, Box<Cause<E>>),
}Expand description
Effect failure algebra: typed errors, defects, fiber interrupts, and composite causes.
Variants§
Fail(E)
Recoverable failure carrying the typed error E.
Die(String)
Defect (panic-style) message.
Interrupt(FiberId)
Fiber interrupted at fiber_id.
Both(Box<Cause<E>>, Box<Cause<E>>)
Parallel composition of two causes.
Then(Box<Cause<E>>, Box<Cause<E>>)
Sequential composition: left observed before right.
Implementations§
Source§impl<E> Cause<E>
impl<E> Cause<E>
Sourcepub fn fail(error: E) -> Self
pub fn fail(error: E) -> Self
Cause::Fail wrapping error.
Sourcepub fn die(message: impl Into<String>) -> Self
pub fn die(message: impl Into<String>) -> Self
Cause::Die with message.
Sourcepub fn interrupt(fiber_id: FiberId) -> Self
pub fn interrupt(fiber_id: FiberId) -> Self
Cause::Interrupt for fiber_id.
Sourcepub fn both(left: Cause<E>, right: Cause<E>) -> Self
pub fn both(left: Cause<E>, right: Cause<E>) -> Self
Cause::Both combining left and right.
Sourcepub fn then(left: Cause<E>, right: Cause<E>) -> Self
pub fn then(left: Cause<E>, right: Cause<E>) -> Self
Cause::Then sequencing left before right.
Sourcepub fn map_fail<E2, F>(self, map: F) -> Cause<E2>
pub fn map_fail<E2, F>(self, map: F) -> Cause<E2>
Map Cause::Fail payloads with map; preserve other variants.
Sourcepub fn fail_option(self) -> Option<E>
pub fn fail_option(self) -> Option<E>
Cause::Fail payload as Some, every other variant as None.
Uses crate::foundation::option_::option::from_predicate on the failure value.
Trait Implementations§
Source§impl<E: Clone + 'static> Semigroup for Cause<E>
Cause<E> with Cause::both forms a commutative semigroup.
impl<E: Clone + 'static> Semigroup for Cause<E>
Cause<E> with Cause::both forms a commutative semigroup.
Law: combine(combine(a, b), c) ≡ combine(a, combine(b, c)) (Both is associative).
impl<E: Hash + Eq + PartialEq> Eq for Cause<E>
Auto Trait Implementations§
impl<E> Freeze for Cause<E>where
E: Freeze,
impl<E> RefUnwindSafe for Cause<E>where
E: RefUnwindSafe,
impl<E> Send for Cause<E>where
E: Send,
impl<E> Sync for Cause<E>where
E: Sync,
impl<E> Unpin for Cause<E>where
E: Unpin,
impl<E> UnsafeUnpin for Cause<E>where
E: UnsafeUnpin,
impl<E> UnwindSafe for Cause<E>where
E: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EffectHash for T
impl<T> EffectHash for T
Source§fn effect_hash(&self) -> u64
fn effect_hash(&self) -> u64
u64 hash of self using the default hasher (Effect.ts-style single-value hash).Source§impl<T> Equal for T
impl<T> Equal for T
Source§fn effect_equals(&self, other: &Self) -> bool
fn effect_equals(&self, other: &Self) -> bool
self and other are structurally equal (defaults to PartialEq::eq).