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:
connectis anArcclone returned throughcore::future::ready, not anasync moveblock. A handle owns a refcount into the backing store rather than borrowing a lifetime from the fixture, which is what letsProjectionFixture::Storebe an ordinary associated type instead of a GAT. A pool-backed fixture does the same thing with a pool; a!Sendfixture does it with anRc.- 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
impl MemoryProjectionFixture
pub fn new() -> Self
pub fn new() -> Self
Creates a fixture over a new, empty MemoryProjectionStore.
Trait Implementations§
§impl Debug for MemoryProjectionFixture
impl Debug for MemoryProjectionFixture
§impl Default for MemoryProjectionFixture
impl Default for MemoryProjectionFixture
§impl ProjectionFixture for MemoryProjectionFixture
impl ProjectionFixture for MemoryProjectionFixture
§const SECOND_HANDLE: Capability = Capability::SUPPORTED
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
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
const COMMIT_FAULT: Capability
Whether this fixture can make a
commit report failure. Read more§const REOPEN: Capability
const REOPEN: Capability
§type Store = MemoryProjectionHandle
type Store = MemoryProjectionHandle
A handle onto this fixture’s backing projection store. Read more
§fn connect(&self) -> impl Future<Output = Self::Store>
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>
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 = ()>
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 = ()>
fn protect_from_reset(&self, id: &ProjectionId) -> impl Future<Output = ()>
Auto Trait Implementations§
impl Freeze for MemoryProjectionFixture
impl RefUnwindSafe for MemoryProjectionFixture
impl Send for MemoryProjectionFixture
impl Sync for MemoryProjectionFixture
impl Unpin for MemoryProjectionFixture
impl UnsafeUnpin for MemoryProjectionFixture
impl UnwindSafe for MemoryProjectionFixture
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
Mutably borrows from an owned value. Read more