pub struct SubjectIndex {
pub subjects: BTreeMap<String, SubjectEntry>,
pub excluded: Vec<String>,
}Expand description
Every subject of a repository, and every test nothing reaches.
use majordomus_cli::evidence::subject::{self, SubjectIndex};
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let s: SubjectIndex = subject::index(&ctx.index, &ctx.product, &ctx.registry);
assert!(s.subjects.keys().any(|k| k.starts_with("capability:")));
assert!(s.excluded.is_empty(), "a synthetic tree carries no tests");Fields§
§subjects: BTreeMap<String, SubjectEntry>Every subject, by key.
excluded: Vec<String>Every test a runner owns in this tree that no route reaches, as test ids, byte order.
Implementations§
Source§impl SubjectIndex
impl SubjectIndex
Sourcepub fn get(&self, key: &str) -> Result<&SubjectEntry, UnknownSubject>
pub fn get(&self, key: &str) -> Result<&SubjectEntry, UnknownSubject>
The subject a key names, or the refusal that names the key.
use majordomus_cli::evidence::subject;
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let s = subject::index(&ctx.index, &ctx.product, &ctx.registry);
assert!(s.get("command:capabilities list").is_ok());
assert!(s.get("gate:x").is_err());Sourcepub fn pages(&self) -> Vec<Page>
pub fn pages(&self) -> Vec<Page>
Every page the site renders, ordered by path. An MCP alias has no page of its own.
use majordomus_cli::evidence::subject;
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let pages = subject::index(&ctx.index, &ctx.product, &ctx.registry).pages();
let paths: Vec<&str> = pages.iter().map(|p| p.path.as_str()).collect();
assert!(paths.windows(2).all(|w| w[0] < w[1]), "ordered by path, each once");Sourcepub fn duplicate_pages(&self) -> Vec<(String, Vec<String>)>
pub fn duplicate_pages(&self) -> Vec<(String, Vec<String>)>
Every page path more than one subject claims, with those subjects’ keys. Empty on a
sound index; artifact refuses to write one that is not.
use majordomus_cli::evidence::subject;
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let s = subject::index(&ctx.index, &ctx.product, &ctx.registry);
assert!(s.duplicate_pages().is_empty());Sourcepub fn reach(&self, key: &str) -> Result<Vec<&Route>, UnknownSubject>
pub fn reach(&self, key: &str) -> Result<Vec<&Route>, UnknownSubject>
Every route a subject reaches: its own routes, then each member’s, depth first in member order, each subject walked once and each route listed once.
This is the one walk of the member graph; the structural finding of a feature is read off it, and a surface that needs what a subject reaches calls it rather than walking the members again.
use majordomus_cli::evidence::subject::{self, Via};
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let s = subject::index(&ctx.index, &ctx.product, &ctx.registry);
// an alias reaches what its capability reaches, and nothing the tree does not carry
let reached = s.reach("mcp:majordomus_capabilities").unwrap();
assert!(reached.iter().all(|r| r.via != Via::Scenario));
assert!(s.reach("feature:no-such").is_err());Sourcepub fn document(&self, version: &str) -> Value
pub fn document(&self, version: &str) -> Value
The committed index as a document: the header, the kinds, the categories, the pages, every subject by key and every test nothing reaches, in that order. Structure only: no commit, no ledger row and no time.
use majordomus_cli::evidence::subject::{self, SCHEMA};
use majordomus_cli::synthetic::SyntheticRepository;
let repo = SyntheticRepository::small().unwrap();
let ctx = repo.context().unwrap();
let doc = subject::index(&ctx.index, &ctx.product, &ctx.registry).document("0.0.0");
assert_eq!(doc["schema"], SCHEMA);
assert_eq!(doc["generator"]["version"], "0.0.0");
let members: Vec<&String> = doc.as_object().unwrap().keys().collect();
assert_eq!(members.first().map(|k| k.as_str()), Some("schema"));
assert_eq!(members.last().map(|k| k.as_str()), Some("excluded"));Trait Implementations§
Source§impl Clone for SubjectIndex
impl Clone for SubjectIndex
Source§fn clone(&self) -> SubjectIndex
fn clone(&self) -> SubjectIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SubjectIndex
impl Debug for SubjectIndex
Source§impl<'de> Deserialize<'de> for SubjectIndex
impl<'de> Deserialize<'de> for SubjectIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for SubjectIndex
Source§impl PartialEq for SubjectIndex
impl PartialEq for SubjectIndex
Source§fn eq(&self, other: &SubjectIndex) -> bool
fn eq(&self, other: &SubjectIndex) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for SubjectIndex
impl Serialize for SubjectIndex
impl StructuralPartialEq for SubjectIndex
Auto Trait Implementations§
impl Freeze for SubjectIndex
impl RefUnwindSafe for SubjectIndex
impl Send for SubjectIndex
impl Sync for SubjectIndex
impl Unpin for SubjectIndex
impl UnsafeUnpin for SubjectIndex
impl UnwindSafe for SubjectIndex
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.