pub struct CallAttachments { /* private fields */ }Expand description
Non-persisted, call-scoped typed attachments handed from before-processors to tool execution.
Each entry is stored behind an Arc keyed by TypeId, keeping
ToolCallContext::clone O(1) per entry during executor dispatch. An
empty CallAttachments allocates nothing. Attachments are never persisted
in crate::Context, never included in ToolResultPayload, and never
sent to model protocols; crate::ToolBatch::resolve_at clears an entry’s
attachments as soon as the call resolves.
Implementations§
Source§impl CallAttachments
impl CallAttachments
Sourcepub fn with<T: Any + Send + Sync>(self, value: T) -> Self
pub fn with<T: Any + Send + Sync>(self, value: T) -> Self
Inserts value and returns self for chained construction. Replaces
any previous attachment of type T.
Sourcepub fn insert<T: Any + Send + Sync>(&mut self, value: T) -> Option<Arc<T>>
pub fn insert<T: Any + Send + Sync>(&mut self, value: T) -> Option<Arc<T>>
Inserts value under TypeId::of::<T>(), returning any previous
attachment of type T.
Sourcepub fn get<T: Any>(&self) -> Option<&T>
pub fn get<T: Any>(&self) -> Option<&T>
Borrows the attachment stored for type T, or None if no attachment
of that exact type is present.
Sourcepub fn contains<T: Any>(&self) -> bool
pub fn contains<T: Any>(&self) -> bool
Returns true when an attachment of exact type T is stored.