pub enum Strategy {
Chain(VecDeque<Strategy>),
Delegated(Box<dyn StrategyLike>),
Single(Runtime),
}
Expand description
Compose strategies for finding PostgreSQL runtimes.
Variants§
Chain(VecDeque<Strategy>)
Each strategy is consulted in turn.
Delegated(Box<dyn StrategyLike>)
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.