pub struct Store { /* private fields */ }Implementations§
Source§impl Store
impl Store
pub fn new(root: PathBuf) -> Self
pub fn root(&self) -> &Path
Sourcepub fn ensure_dirs(&self) -> Result<()>
pub fn ensure_dirs(&self) -> Result<()>
Create the directory tree, owner-only.
Sourcepub fn session_inline_bytes(&self, key: &str) -> u64
pub fn session_inline_bytes(&self, key: &str) -> u64
Base64 bytes already inlined into the Claude session key. Kept on
disk so a restart doesn’t reset it: Claude Code stores every inline
image in its own session transcript, and this is what bounds that.
Sourcepub fn adopt_session_inline_bytes(&self, from: &str, to: &str)
pub fn adopt_session_inline_bytes(&self, from: &str, to: &str)
Fold the counter kept under from into to and remove from. A new
Claude session has no id on its first turn, so that turn is counted
under a per-block key; once the id is known it belongs to the session.
Sourcepub fn refund_session_inline_bytes(&self, key: &str, bytes: u64)
pub fn refund_session_inline_bytes(&self, key: &str, bytes: u64)
Take back bytes counted for a message that wasn’t delivered.
pub fn add_session_inline_bytes(&self, key: &str, bytes: u64)
pub fn blob_path(&self, id: &str, ext: &str) -> PathBuf
Sourcepub fn find_blob(&self, id: &str) -> Option<(PathBuf, FileKind)>
pub fn find_blob(&self, id: &str) -> Option<(PathBuf, FileKind)>
The stored original for id and what kind of file it is.
Sourcepub fn copy_original_to(
&self,
id: &str,
dir: &Path,
name: &str,
) -> Result<PathBuf>
pub fn copy_original_to( &self, id: &str, dir: &Path, name: &str, ) -> Result<PathBuf>
Copy the original of id into dir as name, with the same copy a
drop makes (agentmux_common::copy_into_dir): the name kept valid,
dotfiles included, and de-conflicted exclusively. For container panes,
whose agents can’t see the store
(SPEC_AGENT_PANE_FILE_ATTACHMENTS_2026_09_26.md §7).
Sourcepub fn original(&self, id: &str) -> Option<(PathBuf, String)>
pub fn original(&self, id: &str) -> Option<(PathBuf, String)>
The stored original and its MIME type, whatever kind it is.
Sourcepub fn named_link(&self, id: &str, name: &str) -> Option<PathBuf>
pub fn named_link(&self, id: &str, name: &str) -> Option<PathBuf>
A copy of the original named as the user’s file, for delivery (agents recognise files by extension, and the real name reads better than a hash). A real copy, never a hard link: an agent that edits the file it was given must not change the content-addressed original. Re-copied on every delivery, so an earlier edit never reaches the next message.
pub fn new_incoming_path(&self) -> PathBuf
Sourcepub fn meta(&self, id: &str, fp: &str) -> Option<StoredMeta>
pub fn meta(&self, id: &str, fp: &str) -> Option<StoredMeta>
Stored metadata for fingerprint fp, or None when the id is
invalid, not in the store, or not yet derived for fp.
Sourcepub fn file(&self, id: &str, fp: &str, kind: Kind) -> Option<(PathBuf, String)>
pub fn file(&self, id: &str, fp: &str, kind: Kind) -> Option<(PathBuf, String)>
Path and MIME type of one stored file. Non-images have no separate send-copy (the original is sent) and, except text, no thumbnail file (an SVG is its own thumbnail).
Sourcepub fn touch(&self, id: &str, fp: &str)
pub fn touch(&self, id: &str, fp: &str)
Mark an attachment as used now, so the retention sweep keeps it.
Sourcepub fn mark_sent(&self, id: &str)
pub fn mark_sent(&self, id: &str)
Record that an attachment went to an agent, which moves it from the 7-day unsent window to the full retention window.
Sourcepub fn discard_if_unprocessed(&self, id: &str)
pub fn discard_if_unprocessed(&self, id: &str)
Remove the original of an attachment that has no metadata under any
fingerprint, i.e. one whose processing failed after Self::place
stored it. Without this, a file that sniffs as an image but won’t
decode would sit in blobs/ until the retention sweep.
Sourcepub fn copy_in(
&self,
src: &Path,
on_progress: impl FnMut(u64) -> bool,
) -> Result<(PathBuf, String, u64)>
pub fn copy_in( &self, src: &Path, on_progress: impl FnMut(u64) -> bool, ) -> Result<(PathBuf, String, u64)>
Copy src into incoming/, hashing as it goes. on_progress is
called with the bytes copied so far; returning false cancels.
Returns the incoming path and the hex SHA-256.
Sourcepub fn place(
&self,
incoming: &Path,
id: &str,
name: &str,
) -> Result<(PathBuf, FileKind), ProcessError>
pub fn place( &self, incoming: &Path, id: &str, name: &str, ) -> Result<(PathBuf, FileKind), ProcessError>
Move a hashed file from incoming/ into blobs/, or drop it when the
same bytes are already stored (under whatever extension they were
stored with). name is the user’s file name, used only to classify.
Returns the blob path and what kind of file it is.
Sourcepub fn place_undecoded(
&self,
incoming: &Path,
id: &str,
name: &str,
) -> Result<(), ProcessError>
pub fn place_undecoded( &self, incoming: &Path, id: &str, name: &str, ) -> Result<(), ProcessError>
Self::place without reading the file: no classification (which opens
a ZIP’s directory) and no derivation. The blob keeps the user’s
extension only when it is one a kind would keep, else bin; what it is
is found when something opens it (find_blob).
Sourcepub fn is_unread(&self, id: &str) -> bool
pub fn is_unread(&self, id: &str) -> bool
Whether id was stored without anything read from it and not opened since.
Sourcepub fn blob_len(&self, id: &str) -> Option<u64>
pub fn blob_len(&self, id: &str) -> Option<u64>
The size of the stored original of id, if there is one. Reads nothing from it.
Sourcepub fn has_blob(&self, id: &str) -> bool
pub fn has_blob(&self, id: &str) -> bool
Whether the original of id is stored. Reads nothing from it.
Sourcepub fn derive_and_save(
&self,
id: &str,
blob: &Path,
kind: FileKind,
name: &str,
send_max_edge: u32,
) -> Result<StoredMeta, ProcessError>
pub fn derive_and_save( &self, id: &str, blob: &Path, kind: FileKind, name: &str, send_max_edge: u32, ) -> Result<StoredMeta, ProcessError>
Derive whatever kind needs and write the metadata. Images go through
the image pipeline (decode, thumbnail, send-copy); other files get a
text preview, a text version or PDF facts.
Sourcepub fn remove_text_caches(&self, ids: &[String]) -> usize
pub fn remove_text_caches(&self, ids: &[String]) -> usize
Delete the extracted-text cache of each attachment in ids, under every fingerprint (<id>.<fp>.text.<ext>).
The original and the other derived files stay: the next send finds the metadata incomplete and extracts the
text again (Self::meta). An id that is not an id names nothing. Returns how many files were removed.
Sourcepub fn sweep(&self, retention: Duration) -> usize
pub fn sweep(&self, retention: Duration) -> usize
Delete attachment files unused for retention (or for
UNSENT_MAX_AGE when the attachment was never sent), and
incoming/ leftovers older than an hour. Returns how many files were
removed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Store
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
impl UnwindSafe for Store
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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