Skip to main content

Module conformance

Module conformance 

Source
Expand description

The contract every AsyncStore keeps, checked against a store: what a missing log or file reads as, the length check of the two log writes, names refused, and racing writers, of which exactly one wins. A store’s own tests run check_store on two handles to one empty storage, such as two connections to one database, so it also checks that what one handle writes the other reads.

use std::future::Future;
use std::pin::pin;
use std::task::{Context, Poll, Waker};

use rig_memory::MemoryStore;
use rig_memory::conformance::check_store;

let store = MemoryStore::default();
let other = store.clone();
let check = pin!(check_store(&store, &other));
// A local store's calls are done when made, so one poll finishes it.
let Poll::Ready(checked) = check.poll(&mut Context::from_waker(Waker::noop())) else {
    return Err("pending".into());
};
checked?;

Structs§

Violation
A part of the contract a store broke.

Functions§

check_store
Checks that a and b, two handles to one storage that holds nothing yet, keep AsyncStore’s contract together.