Skip to main content

Talks

Struct Talks 

Source
pub struct Talks { /* private fields */ }
Expand description

A conversation store on disk.

Implementations§

Source§

impl Talks

Source

pub fn open() -> Self

The operator’s conversations, <home>/talks.

Source

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.

Source

pub fn root(&self) -> &Path

Directory holding the conversation files.

Source

pub fn path_of(&self, id: &str) -> PathBuf

Path for one conversation id.

Source

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.

Source

pub fn attachments_dir(&self, id: &str) -> PathBuf

Where this conversation’s attached images live: a subdirectory of artifacts_of, so deleting the conversation deletes its attachments too and nothing here needs its own cleanup path.

Source

pub fn put_attachment( &self, id: &str, mime: &str, name: &str, data: &[u8], ) -> Result<Attachment>

Persist one already-validated attachment and return its metadata.

web::talk_attachment_post is the only caller: it has already checked mime against the whitelist and sniffed the bytes, so an unrecognised mime reaching here is a bug in that caller, not something an operator did. The id is minted here and never taken from the client; name is stored for display only and never used to build a path.

Source

pub fn attachment_meta( &self, id: &str, att_id: &str, ) -> Result<Option<Attachment>>

Just the metadata, without reading the image bytes back off disk - what web::talk_say uses to turn an id the operator referenced into an Attachment before appending a Turn, where the bytes themselves are of no interest. None for an id this conversation never stored - including one that merely looks plausible: valid_attachment_id is checked here too, not only by the caller, the same defence-in-depth Questions::panel_asset uses for its own asset ids.

Source

pub fn read_attachment( &self, id: &str, att_id: &str, ) -> Result<Option<(Attachment, Vec<u8>)>>

A stored attachment’s metadata and its bytes together, for serving it back on GET. None under the same conditions as Talks::attachment_meta, which this is built on.

Source

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.

Source

pub fn get(&self, id: &str) -> Result<Talk>

Load a conversation by id or unambiguous id prefix.

Source

pub fn list(&self) -> Vec<Talk>

Every conversation on disk: open first, then newest first, so what the operator is still using belongs above what they are done with.

Source

pub fn resolve_id(&self, prefix: &str) -> Result<String>

Expand an id prefix to exactly one conversation id.

Source

pub fn revision(&self) -> u64

Change detection token: the newest modification time in the store, in milliseconds.

Source

pub fn count_open(&self) -> usize

How many conversations are still open.

Source

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§

Source§

impl Clone for Talks

Source§

fn clone(&self) -> Talks

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Talks

Source§

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

Formats the value using the given formatter. Read more

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> 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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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