pub struct Talks { /* private fields */ }Expand description
A conversation store on disk.
Implementations§
Source§impl Talks
impl Talks
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 - see crate::chat::Chats::artifacts_of.
Sourcepub fn put(&self, t: &mut Talk) -> Result<()>
pub fn put(&self, t: &mut Talk) -> Result<()>
Write a conversation, atomically, so a process killed mid-write leaves the previous state readable rather than a truncated file.
Sourcepub fn get(&self, id: &str) -> Result<Talk>
pub fn get(&self, id: &str) -> Result<Talk>
Load a conversation by id or unambiguous id prefix.
Sourcepub fn list(&self) -> Vec<Talk>
pub fn list(&self) -> Vec<Talk>
Every conversation on disk: open first, then newest first - the same
ordering crate::chat::Chats::list uses, for the same reason: what
the operator is still using belongs above what they are done with.
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.
Sourcepub fn revision(&self) -> u64
pub fn revision(&self) -> u64
Change detection token, the same shape as
crate::chat::Chats::revision: the newest modification time in the
store, in milliseconds.
Sourcepub fn count_open(&self) -> usize
pub fn count_open(&self) -> usize
How many conversations are still open.
Sourcepub fn remove(&self, id: &str) -> Result<()>
pub fn remove(&self, id: &str) -> Result<()>
Remove a conversation from disk, record and artifacts both. The
operator’s way of saying “not just done, gone” - close alone
leaves the record as history.
Takes Talks::guard for the same reason close does: a delete
racing a record or the tail of [turn] must not land between
their own read and write, or the file removed here would look, to
them, like a record that simply has not been written yet. The other
half of that story is on their side - both check under this same
guard that the record they are about to write is still there, and
give up without writing if it is not, which is what stops their put
from resurrecting a conversation this call already removed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Talks
impl RefUnwindSafe for Talks
impl Send for Talks
impl Sync for Talks
impl Unpin for Talks
impl UnsafeUnpin for Talks
impl UnwindSafe for Talks
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