Skip to main content

MemoryProjectionFixture

Struct MemoryProjectionFixture 

pub struct MemoryProjectionFixture(/* private fields */);
Expand description

The reference ProjectionFixture: one MemoryProjectionStore, any number of handles.

This is the oracle the projection suite is validated against, and it is also the worked example an adapter author reads before writing their own fixture. It is a published item, not a test helper, for exactly that reason: a reference implementation reachable only from inside this crate’s own tests/ is documentation nobody outside can read.

One fixture instance is one MemoryProjectionStore behind an Arc; each connect is a refcount clone, so two handles observe one store and two fixtures share nothing. Two things in it are worth copying:

  • connect is an Arc clone returned through core::future::ready, not an async move block. A handle owns a refcount into the backing store rather than borrowing a lifetime from the fixture, which is what lets ProjectionFixture::Store be an ordinary associated type instead of a GAT. A pool-backed fixture does the same thing with a pool; a !Send fixture does it with an Rc.
  • the handle is a delegating newtype rather than a bare Arc, which is what coherence leaves available.

§Examples

use happenstance_testkit::fixtures::MemoryProjectionFixture;

happenstance_testkit::projection_store_conformance!(MemoryProjectionFixture::new());

Implementations§

§

impl MemoryProjectionFixture

pub fn new() -> Self

Creates a fixture over a new, empty MemoryProjectionStore.

Trait Implementations§

§

impl Debug for MemoryProjectionFixture

§

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

Formats the value using the given formatter. Read more
§

impl Default for MemoryProjectionFixture

§

fn default() -> Self

Returns the “default value” for a type. Read more
§

impl ProjectionFixture for MemoryProjectionFixture

§

const SECOND_HANDLE: Capability = Capability::SUPPORTED

Whether this fixture can hand out a second, independent handle onto the one backing projection store. Read more
§

const RESET_REFUSAL: Capability

Whether this fixture’s store can be made to refuse a reset for a projection it protects. Read more
§

const COMMIT_FAULT: Capability

Whether this fixture can make a commit report failure. Read more
§

const REOPEN: Capability

Whether this fixture can be reopened: every outstanding handle’s process-level state discarded, so that a later connect observes only what was durably committed. Read more
§

type Store = MemoryProjectionHandle

A handle onto this fixture’s backing projection store. Read more
§

fn connect(&self) -> impl Future<Output = Self::Store>

Opens a handle onto this fixture’s backing store. Read more
§

fn reopen(&self) -> impl Future<Output = Reopened>

Closes and reopens the underlying storage, discarding every outstanding handle’s process-level state, and says whether it did. Read more
§

fn arm_commit_fault(&self) -> impl Future<Output = ()>

Arms the store so that the next commit fails. Read more
§

fn protect_from_reset(&self, id: &ProjectionId) -> impl Future<Output = ()>

Puts id under this store’s protection, so the next reset of it is refused. Read more

Auto Trait Implementations§

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> 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, 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