pub struct CaseContext<'a> {
pub index: &'a Index,
}Expand description
What a case provider may look at: the repository’s index, so that a case can name an
object that exists (objects.get needs a real URI) and skip itself when the
repository holds nothing it could ask for.
Fields§
§index: &'a IndexThe index of the repository the benchmark runs against.
Implementations§
Source§impl<'a> CaseContext<'a>
impl<'a> CaseContext<'a>
Sourcepub fn of(ctx: &'a Context) -> Self
pub fn of(ctx: &'a Context) -> Self
The case context of a live context: what a caller that holds a
crate::capability::Context hands to a case provider.
It exists so that reaching a provider does not require reaching into the index at the call site. A benchmark case is declared against the index by design — the vocabulary above says why — and a caller that only wants to run the declaration should not have to open the index to do it, because a page that opens the index has no way of being told apart from a page that reads it (ADR 0012).
use majordomus_cli::capability::CaseContext;
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().expect("a synthetic repository");
let ctx = repo.context().expect("a context");
let cases = CaseContext::of(&ctx);
assert_eq!(cases.index.objects.len(), ctx.index.objects.len());