pub struct PolicyReporter<T> { /* private fields */ }Expand description
Adapter that wraps a FallibleObserver and applies a FailurePolicy.
This turns any fallible reporter into a LoopObserver suitable for
passing to the agent loop.
§Example
use agentkit_reporting::{ChannelReporter, FailurePolicy, PolicyReporter};
let (reporter, rx) = ChannelReporter::pair();
let reporter = PolicyReporter::new(reporter, FailurePolicy::Log);
// `reporter` now implements `LoopObserver` and logs send failures to stderr.Implementations§
Source§impl<T: FallibleObserver> PolicyReporter<T>
impl<T: FallibleObserver> PolicyReporter<T>
Sourcepub fn new(inner: T, policy: FailurePolicy) -> Self
pub fn new(inner: T, policy: FailurePolicy) -> Self
Creates a new PolicyReporter wrapping the given observer with the
specified failure policy.
Sourcepub fn policy(&self) -> FailurePolicy
pub fn policy(&self) -> FailurePolicy
Returns the configured failure policy.
Sourcepub fn take_errors(&mut self) -> Vec<ReportError>
pub fn take_errors(&mut self) -> Vec<ReportError>
Drains and returns all accumulated errors.
Only meaningful when the policy is FailurePolicy::Accumulate.
Subsequent calls return an empty Vec until new errors occur.
Trait Implementations§
Source§impl<T: FallibleObserver> LoopObserver for PolicyReporter<T>
impl<T: FallibleObserver> LoopObserver for PolicyReporter<T>
Source§fn handle_event(&mut self, event: AgentEvent)
fn handle_event(&mut self, event: AgentEvent)
Called synchronously for every
AgentEvent emitted by the loop driver.Auto Trait Implementations§
impl<T> Freeze for PolicyReporter<T>where
T: Freeze,
impl<T> !RefUnwindSafe for PolicyReporter<T>
impl<T> Send for PolicyReporter<T>where
T: Send,
impl<T> Sync for PolicyReporter<T>where
T: Sync,
impl<T> Unpin for PolicyReporter<T>where
T: Unpin,
impl<T> UnsafeUnpin for PolicyReporter<T>where
T: UnsafeUnpin,
impl<T> !UnwindSafe for PolicyReporter<T>
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