#[non_exhaustive]pub struct ExtractionTriggerContext<'a> {
pub agent: &'a LocalAgent,
pub fire: ExtractionFire,
}Expand description
What ExtractionTrigger::attach gets (ExtractionTriggerContext).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.agent: &'a LocalAgentThe agent to register hooks on.
fire: ExtractionFireStarts extraction for the store this trigger is attached to.
Implementations§
Source§impl<'a> ExtractionTriggerContext<'a>
impl<'a> ExtractionTriggerContext<'a>
Sourcepub fn new(agent: &'a LocalAgent, fire: ExtractionFire) -> Self
pub fn new(agent: &'a LocalAgent, fire: ExtractionFire) -> Self
The context a trigger attaches to agent with, firing through fire.
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use strands::memory::{ExtractionFire, ExtractionTrigger, ExtractionTriggerContext, InvocationTrigger};
use strands::testing::{MockModel, test_agent};
let agent = test_agent(MockModel::new());
let fired = Arc::new(AtomicUsize::new(0));
let counter = fired.clone();
let fire = ExtractionFire::new(move |_| {
counter.fetch_add(1, Ordering::SeqCst);
});
InvocationTrigger::new().attach(ExtractionTriggerContext::new(agent.local(), fire));
assert_eq!(fired.load(Ordering::SeqCst), 0);Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ExtractionTriggerContext<'a>
impl<'a> !UnwindSafe for ExtractionTriggerContext<'a>
impl<'a> Freeze for ExtractionTriggerContext<'a>
impl<'a> Send for ExtractionTriggerContext<'a>
impl<'a> Sync for ExtractionTriggerContext<'a>
impl<'a> Unpin for ExtractionTriggerContext<'a>
impl<'a> UnsafeUnpin for ExtractionTriggerContext<'a>
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§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> ⓘ
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 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> ⓘ
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 moreCreates a shared type from an unshared type.