pub trait RoutingStrategy<Route: DeliveryRoute + Clone + PartialEq>: Clone {
type Observation;
type Error;
// Required methods
fn select(
&mut self,
members: &[Route],
message: &<Route::Protocol as Protocol>::Msg,
) -> Option<usize>;
fn observe(
&mut self,
_members: &[Route],
observation: Self::Observation,
) -> Result<(), RoutingObservationRejection<Self::Observation, Self::Error>>;
// Provided methods
fn added(&mut self, _recipient: Route) { ... }
fn removed(&mut self, _index: usize, _recipient: Route, _remaining: usize) { ... }
}Expand description
Static recipient-selection policy used by Router.
Implementations receive the current membership snapshot and return at most
one index into it. Returning an out-of-range index is a typed
RouterError::InvalidSelection; the command is returned and the cloned
policy candidate is discarded without committing policy state. Policies
perform no effects and obtain no ambient entropy.
Required Associated Types§
Sourcetype Observation
type Observation
Closed observation type accepted by this policy.
Required Methods§
Sourcefn select(
&mut self,
members: &[Route],
message: &<Route::Protocol as Protocol>::Msg,
) -> Option<usize>
fn select( &mut self, members: &[Route], message: &<Route::Protocol as Protocol>::Msg, ) -> Option<usize>
Select at most one index from this exact typed membership snapshot.
Returning None means no member is currently eligible. The selected
route receives ownership of the message, so unicast routing does not
require the destination protocol’s message to implement Clone.
Sourcefn observe(
&mut self,
_members: &[Route],
observation: Self::Observation,
) -> Result<(), RoutingObservationRejection<Self::Observation, Self::Error>>
fn observe( &mut self, _members: &[Route], observation: Self::Observation, ) -> Result<(), RoutingObservationRejection<Self::Observation, Self::Error>>
Fold one typed observation against the same membership snapshot.
§Errors
Returns the exact owned observation and concrete reason when evidence is unknown, stale, or contradictory. Router discards the policy candidate on rejection, so no partial policy mutation is committed.
Provided Methods§
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.