pub struct Chats { /* private fields */ }Expand description
A conversation store on disk.
Implementations§
Source§impl Chats
impl Chats
Sourcepub fn at(root: PathBuf) -> Self
pub fn at(root: PathBuf) -> Self
A store at an explicit root. Tests use this, which is why none of them need the operator’s real home.
Sourcepub fn artifacts_of(&self, id: &str) -> PathBuf
pub fn artifacts_of(&self, id: &str) -> PathBuf
Where one conversation’s prompts and CLI output are kept.
Beside the record rather than inside it, with the same stem convention a run’s nodes use, so a conversation that went wrong can be read back turn by turn - which is the only way to tell “the agent said nothing” apart from “magi never asked it”.
Sourcepub fn put(&self, c: &mut Chat) -> Result<()>
pub fn put(&self, c: &mut Chat) -> Result<()>
Write a conversation, atomically, so a process killed mid-write leaves the previous state readable rather than a truncated file that would lose the whole interview.
Sourcepub fn get(&self, id: &str) -> Result<Chat>
pub fn get(&self, id: &str) -> Result<Chat>
Load a conversation by id or unambiguous id prefix.
Sourcepub fn list(&self) -> Vec<Chat>
pub fn list(&self) -> Vec<Chat>
Every conversation on disk: open first, then newest first.
Open first because that ordering is the product - the list exists to show the operator what is still being talked through, and a filed interview is history underneath it. Unreadable files are skipped rather than fatal: one corrupt record must not take the web UI down, and must certainly not hide the open conversation the operator came back for.
Sourcepub fn resolve_id(&self, prefix: &str) -> Result<String>
pub fn resolve_id(&self, prefix: &str) -> Result<String>
Expand an id prefix to exactly one conversation id. The short id the phone shows is a suffix, so that is accepted too.
Sourcepub fn revision(&self) -> u64
pub fn revision(&self) -> u64
Newest modification time in the store, in milliseconds, for change
detection. The web UI compares this instead of re-reading every
conversation, so an idle phone on a slow link costs one stat per file.
Sourcepub fn count_open(&self) -> usize
pub fn count_open(&self) -> usize
How many conversations are still open. The badge on the phone.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Chats
impl RefUnwindSafe for Chats
impl Send for Chats
impl Sync for Chats
impl Unpin for Chats
impl UnsafeUnpin for Chats
impl UnwindSafe for Chats
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more