Skip to main content

Service

Struct Service 

Source
pub struct Service { /* private fields */ }

Implementations§

Source§

impl Service

Source

pub fn new(store: Store, broker: Arc<Broker>, config: Arc<ConfigState>) -> Self

Source

pub fn store(&self) -> &Store

Source

pub fn limits(&self) -> Limits

Source

pub fn ingest( self: &Arc<Self>, req: CommandAttachmentsIngestData, ) -> AttachmentsIngestResult

Classify paths, apply the limits, and (unless dry_run) start processing the accepted images in the background. Returns at once.

Source

pub fn cancel(&self, batch_id: &str) -> bool

Source

pub async fn info(self: &Arc<Self>, ids: &[String]) -> Vec<AttachmentInfo>

Info for each id still in the store, in request order. May decode (after a send-edge change), so call it off the async workers.

Source

pub async fn ensure_derived(self: &Arc<Self>, id: &str) -> Option<StoredMeta>

Metadata under the current fingerprint. When the send edge or the pipeline changed since the attachment was processed, re-derive it from the stored original under the same CPU and memory limits as ingest, so a transcript full of old thumbnails can’t start an unbounded number of decodes at once.

A file stored unread (store_undecoded) is not derived here, so a pane drawing its tile or a thumbnail request leaves it alone: that takes Self::open_derived.

Source

pub async fn open_derived(self: &Arc<Self>, id: &str) -> Option<StoredMeta>

Self::ensure_derived for a file someone has chosen to open or use: one stored unread is derived now.

Source

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

Give back what Self::with_session_inline_budget recorded for a message that then wasn’t delivered. Blocking.

Source

pub fn with_session_inline_budget<T>( &self, key: &str, carry_from: Option<&str>, max: u64, f: impl FnOnce(u64) -> (T, u64), ) -> T

Run f with the inline budget left in Claude session key (out of max), and record what it reports spending, as one step under a lock. carry_from is a per-block key counted before the session had an id; its count moves into key first. Blocking.

Source

pub fn send_target(&self, id: &str, name: &str) -> Option<SendTarget>

What the agent gets for attachment id sent under the user’s name, marking it used: an image’s send-copy, or for any other file a freshly made copy named name, with a note for the agent’s list. Doesn’t decode: call Self::ensure_derived first so a stale fingerprint is re-derived under the limits.

Source

pub async fn store_undecoded( self: &Arc<Self>, tmp: PathBuf, id: String, name: String, ) -> Result<(), ProcessError>

Store a file already sitting in incoming/ exactly as it came: placed under its hash and nothing read from it (no type sniffing, decode, preview or text). It is derived when something opens it (Self::ensure_derived). For a file whose sender is not proven.

Source

pub fn stored_len(&self, id: &str) -> Option<u64>

The size of the stored original of id, from the file system alone.

Source

pub fn unread_target(&self, id: &str, name: &str) -> Option<SendTarget>

What the agent gets for id sent under name when nothing may be read from the file: a named copy of the original and a note saying it was not opened. A file that was derived before (the same bytes from a sender that was proven, or the sender’s own upload) is given as Self::send_target gives it.

Source

pub async fn commit_upload( self: &Arc<Self>, tmp: PathBuf, id: String, name: String, ) -> Result<AttachmentInfo, ProcessError>

Store a file already sitting in incoming/ (an upload): place it, reserve decode memory, derive. Returns its info.

Auto Trait Implementations§

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
§

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