Struct HookSet
pub struct HookSet { /* private fields */ }Expand description
An ordered set of plugins, with their limits. A clone shares the plugins (Arcs): a host that
gives one set to several agents (adam_assembly::BoundDef::hooks) runs the same plugins in each.
Implementations§
§impl HookSet
impl HookSet
pub fn with_observe_limits(self, limits: ObserveLimits) -> HookSet
pub fn with_observe_limits(self, limits: ObserveLimits) -> HookSet
The same set with limits for its observers.
pub fn declared_events(&self) -> Vec<EventSpec>
pub fn declared_events(&self) -> Vec<EventSpec>
The custom events the plugins declare (ADR 0050, slice H5), in plugin order.
pub fn check_events(&self, others: &[EventSpec]) -> Result<(), DeclarationError>
pub fn check_events(&self, others: &[EventSpec]) -> Result<(), DeclarationError>
Whether every plugin’s subscriptions can match something, given the events others (the
tools’ and the agent’s) declare beside the plugins’ own: the declarations are valid and do not
conflict, and each pattern’s namespace is core or declared. The agent’s build calls this.
§Errors
The first DeclarationError.
pub fn observe(&self, events: &[HookEvent]) -> FlushReport
pub fn observe(&self, events: &[HookEvent]) -> FlushReport
Offers events, in order, to every plugin’s observe, in declaration order, when the
plugin’s subscriptions match the event.
An observer’s error, panic or missed deadline is counted in the report and dropped: the
next plugin and the next event are offered as if it had answered. Once the flush has taken
ObserveLimits::per_flush, the events left are dropped and counted.
§impl HookSet
impl HookSet
pub fn with_limits(self, limits: HookLimits) -> HookSet
pub fn with_limits(self, limits: HookLimits) -> HookSet
The same set with limits.
pub fn with(self, plugin: Arc<dyn Plugin>) -> HookSet
pub fn with(self, plugin: Arc<dyn Plugin>) -> HookSet
The same set with plugin appended: the order is the order hooks run in.
pub fn message_received(
&self,
message: &mut HookedMessage<'_>,
) -> Result<Option<Decided<'_>>, HookError>
pub fn message_received( &self, message: &mut HookedMessage<'_>, ) -> Result<Option<Decided<'_>>, HookError>
Runs every plugin’s message_received in order, until one decides. None when every plugin
said Verdict::Continue.
§Errors
As HookSet::before_tool. The caller refuses the message on an error: a hook that cannot
say Continue never lets a message reach a model.
pub fn run_ending(
&self,
end: &HookedEnd<'_>,
) -> Result<Option<Decided<'_>>, HookError>
pub fn run_ending( &self, end: &HookedEnd<'_>, ) -> Result<Option<Decided<'_>>, HookError>
Runs every plugin’s run_ending in order, until one decides. None when every plugin allowed
the end.
§Errors
pub fn before_tool(
&self,
call: &mut HookedCall<'_>,
) -> Result<Verdict, HookError>
pub fn before_tool( &self, call: &mut HookedCall<'_>, ) -> Result<Verdict, HookError>
Runs every plugin’s before_tool in order, until one denies or stops.
An Verdict::Ask does not end the set (ADR 0050, decision 8 and slice H8): the plugins
after it are still asked, each seeing the arguments the ones before it left, because a call a
person approves runs, and a plugin that would have refused it must have had its say. A later
Deny or Stop, or a later failure, is the set’s answer; a later Ask adds nothing (the
first question stands). The set answers the first Ask only when no plugin after it refused.
§Errors
The first plugin that panics, errors or misses its deadline, after a retryable failure has
been tried again HookLimits::retries times. The caller denies on an error: a hook that
cannot say Continue never lets the call through.
pub fn model_request(
&self,
request: &mut HookedModelRequest<'_>,
) -> Result<Verdict, HookError>
pub fn model_request( &self, request: &mut HookedModelRequest<'_>, ) -> Result<Verdict, HookError>
Runs every plugin’s model_request in order, until one decides.
§Errors
As HookSet::before_tool. The caller does not make the call on an error.
pub fn compaction_before(
&self,
compaction: &mut HookedCompaction<'_>,
) -> Result<Verdict, HookError>
pub fn compaction_before( &self, compaction: &mut HookedCompaction<'_>, ) -> Result<Verdict, HookError>
Runs every plugin’s compaction_before in order, until one decides.
§Errors
As HookSet::before_tool. The caller does not summarise on an error: the run fails for
good (decision 8); only a Verdict::Deny shortens the history instead.
pub fn after_tool(
&self,
call: &HookedCall<'_>,
output: &mut HookedText<'_>,
) -> Result<Verdict, HookError>
pub fn after_tool( &self, call: &HookedCall<'_>, output: &mut HookedText<'_>, ) -> Result<Verdict, HookError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for HookSet
impl !UnwindSafe for HookSet
impl Freeze for HookSet
impl Send for HookSet
impl Sync for HookSet
impl Unpin for HookSet
impl UnsafeUnpin for HookSet
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].