pub trait Policy: Sized {
// Required method
fn handle(overflow: &mut VecDeque<Self>, message: Self) -> bool;
}Expand description
Overflow behavior for actor messages when an inbox is full.
Required Methods§
Sourcefn handle(overflow: &mut VecDeque<Self>, message: Self) -> bool
fn handle(overflow: &mut VecDeque<Self>, message: Self) -> bool
Handle message when it cannot enter the bounded ready queue immediately.
Messages already in the ready queue are not provided here. Policy changes only apply to overflow retained beyond ready capacity. Policies may append, remove, replace, reorder, or clear overflow, and are responsible for bounding it when a hard memory limit is required.
The returned value is feedback for this enqueue attempt after the policy has made any
overflow changes. Return true to report Feedback::Backoff or
false to report Feedback::Dropped.
§Warning
Do not enqueue into the same mailbox from this method or from destructors triggered by
editing overflow. This method runs while the mailbox holds its overflow lock, so same
mailbox re-entry can deadlock.
This method should not unwind after mutating overflow. A panic, including one from a
destructor triggered while editing overflow, can leave retained overflow data stranded in
the mailbox.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.