pub struct Store {
root: PathBuf,
}Fields§
§root: PathBufImplementations§
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.
fn session_path(&self, key: &str) -> PathBuf
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.
pub fn add_session_inline_bytes(&self, key: &str, bytes: u64)
fn shard(id: &str) -> &str
pub fn blob_path(&self, id: &str, ext: &str) -> PathBuf
fn derived_path(&self, id: &str, fp: &str, suffix: &str) -> PathBuf
fn meta_path(&self, id: &str, fp: &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.
Sourcefn existing_blob(&self, id: &str) -> Option<PathBuf>
fn existing_blob(&self, id: &str) -> Option<PathBuf>
An existing original for id, whatever extension it was stored with.
fn named_path(&self, id: &str, name: &str) -> PathBuf
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.
Sourcefn meta_files(&self, id: &str, fp: &str, meta: &StoredMeta) -> Vec<PathBuf>
fn meta_files(&self, id: &str, fp: &str, meta: &StoredMeta) -> Vec<PathBuf>
The derived files meta says exist (not the original).
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.
fn sent_marker(&self, id: &str) -> PathBuf
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.
fn is_sent(&self, id: &str) -> bool
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 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.
Sourcefn derive_image(
&self,
id: &str,
blob: &Path,
format: ImageFormat,
send_max_edge: u32,
) -> Result<StoredMeta, ProcessError>
fn derive_image( &self, id: &str, blob: &Path, format: ImageFormat, send_max_edge: u32, ) -> Result<StoredMeta, ProcessError>
Decode a stored image and write its thumbnail, send-copy and
metadata under fingerprint fingerprint(send_max_edge).
Sourcefn derive_file(
&self,
id: &str,
blob: &Path,
kind: FileKind,
name: &str,
send_max_edge: u32,
) -> Result<StoredMeta, ProcessError>
fn derive_file( &self, id: &str, blob: &Path, kind: FileKind, name: &str, send_max_edge: u32, ) -> Result<StoredMeta, ProcessError>
Metadata and derived files for a non-image attachment: a preview for text, a text version for Office documents and PDFs, a page count and macro flag where they apply. Failures to extract never fail the attachment; it is still sent by path, with a note.
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