pub enum Selector {
Seed,
Relation,
ScopePath,
Contract,
Governance,
SessionState,
IntentMatch,
}Expand description
What reached an entry. This is the provenance of the selection, and it is a different
fact from the provenance of the file: Relation says the compiler followed an edge the
layer declares, IntentMatch says it guessed from words. An answer that did not keep
them apart could not say which half of itself to trust.
The division that matters is Selector::declared, and it is deliberately lopsided:
six of the seven selectors follow something the repository states, and exactly one
guesses. That ratio is the design. Inference is confined to a single selector so that
the inferred part of any answer can be found, weighed and ignored, rather than being
mixed through the rest at unmarked strength.
use majordomus_cli::devcontext::Selector;
// exactly one selector infers, and the answer can always be split on it
let inferred: Vec<&str> = Selector::ALL
.iter()
.filter(|s| !s.declared())
.map(|s| s.as_str())
.collect();
assert_eq!(inferred, ["intent_match"]);
// every selector has its own word, so a reason is never ambiguous
let mut words: Vec<&str> = Selector::ALL.iter().map(|s| s.as_str()).collect();
let before = words.len();
words.sort();
words.dedup();
assert_eq!(words.len(), before);
// and the word is the serialised form
assert_eq!(
serde_json::to_value(Selector::ScopePath).unwrap(),
serde_json::json!("scope_path"),
);Variants§
Seed
Named in the request.
Relation
Reached along a typed edge of the composed graph.
ScopePath
Its path lies under a path the request or a seed declares.
Contract
A directory contract that reaches one of those paths.
Governance
A rule or policy the layer applies to everything.
SessionState
A recorded session of this branch or of these paths, the handover the resolver chose, the newest checkpoint.
IntentMatch
Inferred: the words of the intent occur in the object’s own words.
Implementations§
Source§impl Selector
impl Selector
Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
The word this selector is reported under.
use majordomus_cli::devcontext::Selector;
assert_eq!(Selector::ScopePath.as_str(), "scope_path");Sourcepub fn declared(self) -> bool
pub fn declared(self) -> bool
Did the repository state this, or did the compiler infer it? A declared selector carries confidence 1.0; an inferred one carries less, and says how much.
use majordomus_cli::devcontext::Selector;
assert!(Selector::Contract.declared());
assert!(!Selector::IntentMatch.declared());Trait Implementations§
impl Copy for Selector
Source§impl<'de> Deserialize<'de> for Selector
impl<'de> Deserialize<'de> for Selector
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 Selector
Source§impl JsonSchema for Selector
impl JsonSchema for Selector
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ord for Selector
impl Ord for Selector
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Selector
impl PartialOrd for Selector
impl StructuralPartialEq for Selector
Auto Trait Implementations§
impl Freeze for Selector
impl RefUnwindSafe for Selector
impl Send for Selector
impl Sync for Selector
impl Unpin for Selector
impl UnsafeUnpin for Selector
impl UnwindSafe for Selector
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.