#[non_exhaustive]pub struct ContextInjectorConfig {
pub name: Option<String>,
pub trigger: Option<InjectionTrigger>,
pub render_content: RenderContent,
}Expand description
Configuration for the ContextInjector plugin (ContextInjectorConfig).
The render callback is required, so the config has no Default; start from
ContextInjectorConfig::new.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: Option<String>Plugin name, for logging and duplicate detection. Defaults to strands:context-injector.
It is stored with every block the injector writes and keeps a retried call from writing
again, also after a session restore, so keep it stable and give each injector its own.
trigger: Option<InjectionTrigger>When to inject. Defaults to InjectionTrigger::UserTurn.
render_content: RenderContentRenders the text to write into the latest user message; Ok(None) or blank text skips.
The text reaches the model verbatim, so escape any attacker-influenced fields yourself.
Called at most once per user message: a retry, a forced structured output call or a resume
sends the text it returned the first time. An error fails open (logged, injection skipped).
Implementations§
Source§impl ContextInjectorConfig
impl ContextInjectorConfig
Sourcepub fn new<F, Fut>(render_content: F) -> Self
pub fn new<F, Fut>(render_content: F) -> Self
A config with the render callback and the default name and trigger.
Sourcepub fn with_trigger(self, trigger: InjectionTrigger) -> Self
pub fn with_trigger(self, trigger: InjectionTrigger) -> Self
Sets the trigger.
Trait Implementations§
Source§impl Clone for ContextInjectorConfig
impl Clone for ContextInjectorConfig
Auto Trait Implementations§
impl !RefUnwindSafe for ContextInjectorConfig
impl !UnwindSafe for ContextInjectorConfig
impl Freeze for ContextInjectorConfig
impl Send for ContextInjectorConfig
impl Sync for ContextInjectorConfig
impl Unpin for ContextInjectorConfig
impl UnsafeUnpin for ContextInjectorConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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> ⓘ
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