pub struct PathStrategy {
pub policies: Vec<Arc<dyn PathPolicy>>,
pub scoring: PathScorer,
}Expand description
PathStrategy combines multiple path operations into a single strategy.
Fields§
§policies: Vec<Arc<dyn PathPolicy>>The path policies to apply.
scoring: PathScorerThe path ranking functions to apply.
Implementations§
Source§impl PathStrategy
impl PathStrategy
Sourcepub fn add_policy(&mut self, policy: impl PathPolicy)
pub fn add_policy(&mut self, policy: impl PathPolicy)
Appends a path policy to the list of policies.
Sourcepub fn add_scoring(&mut self, scoring: impl PathScoring, impact: f32)
pub fn add_scoring(&mut self, scoring: impl PathScoring, impact: f32)
Adds a path scorer with the given impact weight.
Scores from paths are used to select the best path among multiple candidates.
scorer - The path scorer to add.
impact - The weight of the scorer in the final score aggregation.
e.g. Impact of 0.2 means the scorer can change the final score by up to ±0.2.
Note: The impact weight does not need to sum to 1.0 across all scorers.
Sourcepub fn rank_order(
&self,
this: &PathManagerPath,
other: &PathManagerPath,
now: SystemTime,
) -> Ordering
pub fn rank_order( &self, this: &PathManagerPath, other: &PathManagerPath, now: SystemTime, ) -> Ordering
Ranks the order of two paths based on preference.
§Return
Returns the preference ordering between two paths.
Ordering::Lessifthisis preferred overotherOrdering::Greaterifotheris preferred overthisOrdering::Equalif both paths are equally preferred
Sourcepub fn rank_inplace(&self, path: &mut [PathManagerPath], now: SystemTime)
pub fn rank_inplace(&self, path: &mut [PathManagerPath], now: SystemTime)
Sorts the given paths in place, placing the most preferred paths first.
If no ranking functions are added, the paths are not modified.
Sourcepub fn predicate(&self, path: &Path) -> bool
pub fn predicate(&self, path: &Path) -> bool
Returns true if the given path is accepted by all policies.
If no policies are added, all paths are accepted.
Sourcepub fn filter_inplace<'path: 'iter, 'iter>(&self, paths: &mut Vec<Path>)
pub fn filter_inplace<'path: 'iter, 'iter>(&self, paths: &mut Vec<Path>)
Filters the given paths based on all policies, removing paths that are not accepted.
Trait Implementations§
Source§impl Default for PathStrategy
impl Default for PathStrategy
Source§fn default() -> PathStrategy
fn default() -> PathStrategy
Auto Trait Implementations§
impl Freeze for PathStrategy
impl !RefUnwindSafe for PathStrategy
impl Send for PathStrategy
impl Sync for PathStrategy
impl Unpin for PathStrategy
impl !UnwindSafe for PathStrategy
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request