pub struct PathStrategy {
pub policies: Vec<Arc<dyn PathPolicy>>,
pub ranking: Vec<Arc<dyn PathRanking>>,
}Expand description
PathStrategy combines multiple path operations into a single strategy.
Fields§
§policies: Vec<Arc<dyn PathPolicy>>The path policies to apply.
ranking: Vec<Arc<dyn PathRanking>>The 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_ranking(&mut self, ranking: impl PathRanking)
pub fn add_ranking(&mut self, ranking: impl PathRanking)
Appends a path ranking function to the list of ranking functions.
Sourcepub fn predicate(&self, path: &PathManagerPath) -> bool
pub fn predicate(&self, path: &PathManagerPath) -> bool
Returns true if the given path is accepted by all policies.
If no policies are added, all paths are accepted.
Sourcepub fn rank_order(
&self,
this: &PathManagerPath,
other: &PathManagerPath,
) -> Ordering
pub fn rank_order( &self, this: &PathManagerPath, other: &PathManagerPath, ) -> 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 filter_inplace<'path: 'iter, 'iter>(
&self,
paths: &mut Vec<PathManagerPath>,
)
pub fn filter_inplace<'path: 'iter, 'iter>( &self, paths: &mut Vec<PathManagerPath>, )
Filters the given paths based on all policies, removing paths that are not accepted.
Sourcepub fn rank_inplace<'path: 'iter, 'iter>(&self, path: &mut [PathManagerPath])
pub fn rank_inplace<'path: 'iter, 'iter>(&self, path: &mut [PathManagerPath])
Sorts the given paths in place, placing the most preferred paths first.
Uses the ranking functions in the order they were added.
If no ranking functions are added, the paths are not modified.
Trait Implementations§
Source§impl Default for PathStrategy
impl Default for PathStrategy
Source§fn default() -> PathStrategy
fn default() -> PathStrategy
Returns the “default value” for a type. Read more
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
Mutably borrows from an owned value. Read more
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request