pub struct QuestionStore { /* private fields */ }Implementations§
Source§impl QuestionStore
impl QuestionStore
pub fn default_root() -> Result<PathBuf>
pub fn open(root: impl Into<PathBuf>) -> Result<Self>
Sourcepub fn open_existing_default() -> Option<Self>
pub fn open_existing_default() -> Option<Self>
Open at the default location only if it already exists — for read paths that must not create state as a side effect. Doctor’s rule: an examination that creates what it was about to report is measuring itself.
pub fn root(&self) -> &Path
Sourcepub fn lock(&self) -> Result<QuestionLock>
pub fn lock(&self) -> Result<QuestionLock>
Take the writer lock. Held across a read-modify-write, never across an
$EDITOR or a run.
Sourcepub fn items(&self) -> Result<Vec<Question>>
pub fn items(&self) -> Result<Vec<Question>>
Every question, newest first. An unreadable record is skipped rather than failing the listing — one corrupt file must not hide the queue.
pub fn open_items(&self) -> Result<Vec<Question>>
pub fn get(&self, id: &str) -> Result<Question>
Sourcepub fn short(id: &str) -> &str
pub fn short(id: &str) -> &str
The distinguishing tail of an id, for display.
Not a prefix, and that is the whole point. Session::new_id is
YYYYMMDDTHHMMSS-xxxxxxxx, so the leading characters are a timestamp:
abbreviating to the first eight gives every question asked on the same
day the identical handle. Printed one, it looked like an id and was a
date. serve::resume_key reached the same conclusion about the same
ids and takes the tail too.
Sourcepub fn find(&self, needle: &str) -> Result<Question>
pub fn find(&self, needle: &str) -> Result<Question>
Resolve an abbreviated id — head or tail — and refuse an ambiguous one rather than guessing, the way the outbox and sessions do.
pub fn put(&self, q: &Question) -> Result<()>
Sourcepub fn park(
&self,
question: &str,
options: Vec<String>,
session_id: &str,
task_id: Option<String>,
workspace: Option<PathBuf>,
taint: Taint,
) -> Result<Question>
pub fn park( &self, question: &str, options: Vec<String>, session_id: &str, task_id: Option<String>, workspace: Option<PathBuf>, taint: Taint, ) -> Result<Question>
Record a question and hand back what was stored.
Sourcepub fn answer(&self, id: &str, answer: &str) -> Result<Question>
pub fn answer(&self, id: &str, answer: &str) -> Result<Question>
Record the owner’s answer. Returns the question as it now stands.
Answering does not itself resume anything — the caller does that, and the split is deliberate: a store that started agent runs would be a store that can spend the model, and this one is meant to be safe for a listing to touch.
Sourcepub fn abandon(&self, id: &str) -> Result<Question>
pub fn abandon(&self, id: &str) -> Result<Question>
Give up on a question without answering it.
The answer stays None on purpose. Abandoning is a decision about the
question, not a reply to it, and writing “abandoned” into the answer
would put words in the owner’s mouth in the transcript a later resume
reads back.