StrategyLike

Trait StrategyLike 

Source
pub trait StrategyLike:
    Debug
    + RefUnwindSafe
    + 'static {
    // Required method
    fn runtimes(&self) -> Runtimes<'_>;

    // Provided methods
    fn select(&self, constraint: &Constraint) -> Option<Runtime> { ... }
    fn fallback(&self) -> Option<Runtime> { ... }
}
Expand description

A strategy for finding PostgreSQL runtimes.

There are a few questions we want to answer:

  1. What runtimes are available?
  2. Which of those runtimes is best suited to running a given cluster?
  3. When there are no constraints, what runtime should we use?

This trait models those questions, and provides default implementations for #2 and #3.

However, a good place to start is the Default implementation of Strategy. It might do what you need.

Required Methods§

Source

fn runtimes(&self) -> Runtimes<'_>

Find all runtimes that this strategy knows about.

Provided Methods§

Source

fn select(&self, constraint: &Constraint) -> Option<Runtime>

Determine the most appropriate runtime known to this strategy for the given constraint.

The default implementation narrows the list of runtimes to those that match the given constraint, then chooses the one with the highest version number. It might return None.

Source

fn fallback(&self) -> Option<Runtime>

The runtime to use when there are no constraints, e.g. when creating a new cluster.

The default implementation selects the runtime with the highest version number.

Implementors§