pub(crate) trait Policy {
// Required methods
fn is_blocking(&self) -> bool;
fn take_one(&mut self) -> Result<(), Bug>;
}Expand description
A policy that describes whether cells can be sent on a SinkBlocker.
Each Policy object can be in different states:
some states cause the SinkBlocker to block traffic,
and some cause the SinkBlocker to permit traffic.
The user of a SinkBlocker is expected to call
update_policy() from time to time,
when they need to make a manual change in the SinkBlocker’s status.
This is the only way for a blocked SinkBlocker to become unblocked.
Invariants:
- The state of a
Policyobject may transition from non-blocking to blocking. - The state of a
Policyobject may not transition from blocking to non-blocking. - If
is_blocking()has returned false, and no intervening changes have been made to thePolicy,take_one()will succeed.
Note that because of this last invariant, interior mutability is strongly discouraged for implementations of this trait.
Required Methods§
Sourcefn is_blocking(&self) -> bool
fn is_blocking(&self) -> bool
Returns true if this policy is currently blocking.
Invariant: If this returns true on a given Policy, it must always return true on that Policy in the future. (That is, a Policy may become blocked, but may not become unblocked.)