pub enum Strategy {
Chain(VecDeque<Strategy>),
Delegated(Box<dyn StrategyLike + Send + Sync>),
Single(Runtime),
}
Expand description
Compose strategies for finding PostgreSQL runtimes.
Variants§
Chain(VecDeque<Strategy>)
Each strategy is consulted in turn.
Delegated(Box<dyn StrategyLike + Send + Sync>)
Delegate to another strategy; needed when implementing StrategyLike
.
Single(Runtime)
A single runtime; it always picks itself.
Implementations§
Source§impl Strategy
impl Strategy
Sourcepub fn push_front<S: Into<Strategy>>(self, strategy: S) -> Self
pub fn push_front<S: Into<Strategy>>(self, strategy: S) -> Self
Push the given strategy to the front of the chain.
If this isn’t already, it is converted into a Strategy::Chain
.
Sourcepub fn push_back<S: Into<Strategy>>(self, strategy: S) -> Self
pub fn push_back<S: Into<Strategy>>(self, strategy: S) -> Self
Push the given strategy to the back of the chain.
If this isn’t already, it is converted into a Strategy::Chain
.
Trait Implementations§
Source§impl From<Runtime> for Strategy
impl From<Runtime> for Strategy
Source§fn from(runtime: Runtime) -> Self
fn from(runtime: Runtime) -> Self
Converts the given runtime into a Strategy::Single
.
Source§impl From<RuntimesOnPath> for Strategy
impl From<RuntimesOnPath> for Strategy
Source§fn from(strategy: RuntimesOnPath) -> Self
fn from(strategy: RuntimesOnPath) -> Self
Converts the given strategy into a Strategy::Delegated
.
Source§impl From<RuntimesOnPathEnv> for Strategy
impl From<RuntimesOnPathEnv> for Strategy
Source§fn from(strategy: RuntimesOnPathEnv) -> Self
fn from(strategy: RuntimesOnPathEnv) -> Self
Converts the given strategy into a Strategy::Delegated
.
Source§impl From<RuntimesOnPlatform> for Strategy
impl From<RuntimesOnPlatform> for Strategy
Source§fn from(strategy: RuntimesOnPlatform) -> Self
fn from(strategy: RuntimesOnPlatform) -> Self
Converts the given strategy into a Strategy::Delegated
.
Source§impl StrategyLike for Strategy
impl StrategyLike for Strategy
Source§fn runtimes(&self) -> Runtimes<'_>
fn runtimes(&self) -> Runtimes<'_>
- For a
Strategy::Chain
, yields runtimes known to all strategies, in the same order as each strategy returns them. - For a
Strategy::Delegated
, calls through to the wrapped strategy. - For a
Strategy::Single
, yields the runtime it’s holding.
Note that for the first two, runtimes are deduplicated by version number, i.e. if a runtime with the same version number is yielded by multiple strategies, or is yielded multiple times by a single strategy, it will only be returned the first time it is seen.
Source§fn select(&self, constraint: &Constraint) -> Option<Runtime>
fn select(&self, constraint: &Constraint) -> Option<Runtime>
- For a
Strategy::Chain
, asks each strategy in turn to select a runtime. The first non-None
answer is selected. - For a
Strategy::Delegated
, calls through to the wrapped strategy. - For a
Strategy::Single
, returns the runtime if it’s compatible.
Source§fn fallback(&self) -> Option<Runtime>
fn fallback(&self) -> Option<Runtime>
- For a
Strategy::Chain
, asks each strategy in turn for a fallback runtime. The first non-None
answer is selected. - For a
Strategy::Delegated
, calls through to the wrapped strategy. - For a
Strategy::Single
, returns the runtime it’s holding.
Auto Trait Implementations§
impl Freeze for Strategy
impl RefUnwindSafe for Strategy
impl Send for Strategy
impl Sync for Strategy
impl Unpin for Strategy
impl !UnwindSafe for Strategy
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 more