Skip to main content

FaultyStoreError

Enum FaultyStoreError 

#[non_exhaustive]
pub enum FaultyStoreError<E> { Injected, Contended, Store(E), }
Expand description

Why a read or an append through a faulty wrapper failed.

The wrapper cannot report the inner store’s error as its own. The reference store’s is pub enum MemoryStoreError {} — uninhabited — so there is no value of it to yield for an injected failure. Projecting this type is what lets the wrapper compile over a store that cannot fail, and what lets a caller tell the fixture broke this on purpose from my store failed, which is the one question a test against a fixture has to answer.

§Examples

use happenstance_core::{EventStore, MemoryEventStore};
use happenstance_core::{Query, ReadOptions};
use happenstance_testkit::{FaultyStore, FaultyStoreError};

let store = FaultyStore::new(MemoryEventStore::new()).fail_next_read(1);
let first = happenstance_testkit::block_on(async {
    happenstance_core::collect(
        store.read(&Query::all(), ReadOptions::new()),
    )
    .await
});
assert!(matches!(first, Err(FaultyStoreError::Injected)));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Injected

The wrapper produced this failure because it was armed to.

§

Contended

The wrapper refused this append the way a contended store refuses one.

Transient, and that is the entire point. Nothing underneath went wrong, nothing was written, and the identical call succeeds once the arming is spent — the shape SQLite produces as SQLITE_BUSY when a writer waits out busy_timeout without ever acquiring the lock, and PostgreSQL as a serialisation failure.

It is deliberately not Injected. That variant means the fixture broke this on purpose; this one means the fixture was busy, and a caller that cannot tell them apart is the defect this variant exists to make testable.

§Which channel it arrives on, and why that is the whole instrument

It reaches a caller as AppendError::Busy(FaultyStoreError::Contended): the contract’s transient-refusal channel (ES-43), with this variant as the adapter’s own payload, exactly as a real adapter carries its driver’s error there. AppendError::is_busy answers true and AppendError::is_condition_violated answers false.

Until Busy existed it arrived as AppendError::Store, the channel a caller cannot tell from a real breakage, and that conflation was what this variant was built to make testable. It moved in the same release that minted the channel, before either shipped.

Routing it through ConditionViolated instead would be a fixture telling a lie a real store never tells: no condition was evaluated, because the lock was never taken.

§

Store(E)

The wrapped store failed for its own reasons.

The inner error is carried, never rendered: it stays reachable through source so a caller reports the real failure rather than this wrapper’s description of it.

Trait Implementations§

§

impl<E: Clone> Clone for FaultyStoreError<E>

§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<E: Copy> Copy for FaultyStoreError<E>

§

impl<E: Debug> Debug for FaultyStoreError<E>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl<E: Display> Display for FaultyStoreError<E>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl<E: Eq> Eq for FaultyStoreError<E>

§

impl<E: Error + 'static> Error for FaultyStoreError<E>

§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
§

impl<E: PartialEq> PartialEq for FaultyStoreError<E>

§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl<E: PartialEq> StructuralPartialEq for FaultyStoreError<E>

Auto Trait Implementations§

§

impl<E> Freeze for FaultyStoreError<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for FaultyStoreError<E>
where E: RefUnwindSafe,

§

impl<E> Send for FaultyStoreError<E>
where E: Send,

§

impl<E> Sync for FaultyStoreError<E>
where E: Sync,

§

impl<E> Unpin for FaultyStoreError<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for FaultyStoreError<E>
where E: UnsafeUnpin,

§

impl<E> UnwindSafe for FaultyStoreError<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V