Skip to main content

Loaded

Struct Loaded 

Source
pub struct Loaded {
    pub records: Vec<ReasoningRecord>,
    pub unreadable: Vec<String>,
}
Expand description

The records of a store, read.

Records are kept in canonical order, recorded_at then id, and every query of this module reads them in that order. A file that does not parse, or that carries another schema or version, is listed in unreadable instead of being dropped silently. The default is the empty store, which is what admission sees before anything is written.

use majordomus_cli::reasoning::store::{Loaded, Store};

let dir = tempfile::tempdir().unwrap();
let task = dir.path().join(".ai/local/state/reasoning/t");
std::fs::create_dir_all(&task).unwrap();
std::fs::write(task.join("broken.json"), "{ not json").unwrap();

let loaded: Loaded = Store::at(dir.path()).load();
assert!(loaded.records.is_empty());
assert_eq!(loaded.unreadable, ["t/broken.json"]);

Fields§

§records: Vec<ReasoningRecord>

Every record that parsed, ordered by recorded_at then id.

§unreadable: Vec<String>

Files that did not parse, by path relative to the store.

Implementations§

Source§

impl Loaded

Source

pub fn get(&self, id: &str) -> Option<&ReasoningRecord>

The record with this id, or None when no loaded record carries it.

Ids are unique in a store, so the first match is the only one.

use majordomus_cli::reasoning::record::*;
use majordomus_cli::reasoning::store::Loaded;

let mut loaded = Loaded::default();
loaded.records.push(ReasoningRecord {
    schema: RECORD_SCHEMA.into(),
    version: RECORD_VERSION,
    id: "assessment-1".into(),
    task: "t".into(),
    recorded_at: "2026-10-01T00:00:01Z".into(),
    head: None,
    redacted: vec![],
    body: ReasoningBody::Assessment(AssessmentInput::default()),
});
assert_eq!(loaded.get("assessment-1").map(|r| r.body.kind()), Some("assessment"));
assert!(loaded.get("assessment-2").is_none());

Trait Implementations§

Source§

impl Debug for Loaded

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Loaded

Source§

fn default() -> Loaded

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more