Skip to main content

Store

Struct Store 

Source
pub struct Store {
    root: PathBuf,
}

Fields§

§root: PathBuf

Implementations§

Source§

impl Store

Source

pub fn new(root: PathBuf) -> Self

Source

pub fn root(&self) -> &Path

Source

pub fn ensure_dirs(&self) -> Result<()>

Create the directory tree, owner-only.

Source

fn session_path(&self, key: &str) -> PathBuf

Source

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.

Source

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.

Source

pub fn add_session_inline_bytes(&self, key: &str, bytes: u64)

Source

fn shard(id: &str) -> &str

Source

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

Source

fn derived_path(&self, id: &str, fp: &str, suffix: &str) -> PathBuf

Source

fn meta_path(&self, id: &str, fp: &str) -> PathBuf

Source

pub fn find_blob(&self, id: &str) -> Option<(PathBuf, FileKind)>

The stored original for id and what kind of file it is.

Source

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).

Source

pub fn original(&self, id: &str) -> Option<(PathBuf, String)>

The stored original and its MIME type, whatever kind it is.

Source

fn existing_blob(&self, id: &str) -> Option<PathBuf>

An existing original for id, whatever extension it was stored with.

Source

fn named_path(&self, id: &str, name: &str) -> 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.

Source

pub fn new_incoming_path(&self) -> PathBuf

Source

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.

Source

fn meta_files(&self, id: &str, fp: &str, meta: &StoredMeta) -> Vec<PathBuf>

The derived files meta says exist (not the original).

Source

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).

Source

pub fn touch(&self, id: &str, fp: &str)

Mark an attachment as used now, so the retention sweep keeps it.

Source

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

Source

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.

Source

fn is_sent(&self, id: &str) -> bool

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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§

Source§

impl Clone for Store

Source§

fn clone(&self) -> Store

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 Store

Source§

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

Formats the value using the given formatter. Read more

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

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

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

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

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

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

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
§

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

§

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
§

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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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