Skip to main content

BackendSelection

Trait BackendSelection 

Source
pub trait BackendSelection: Sized {
    type Iter;
    type Config;

    // Required methods
    fn build(backends: &BTreeSet<Backend>) -> Self;
    fn iter(self: &Arc<Self>, key: &[u8]) -> Self::Iter
       where Self::Iter: BackendIter;

    // Provided method
    fn build_with_config(
        backends: &BTreeSet<Backend>,
        _config: &Self::Config,
    ) -> Self { ... }
}
Expand description

BackendSelection is the interface to implement backend selection mechanisms.

Required Associated Types§

Source

type Iter

The BackendIter returned from iter() below.

Source

type Config

The configuration type constructing BackendSelection

Required Methods§

Source

fn build(backends: &BTreeSet<Backend>) -> Self

The function to create a BackendSelection implementation.

Source

fn iter(self: &Arc<Self>, key: &[u8]) -> Self::Iter
where Self::Iter: BackendIter,

Select backends for a given key.

An BackendIter should be returned. The first item in the iter is the first choice backend. The user should continue to iterate over it if the first backend cannot be used due to its health or other reasons.

Provided Methods§

Source

fn build_with_config( backends: &BTreeSet<Backend>, _config: &Self::Config, ) -> Self

Create a BackendSelection from a set of backends and the given configuration. The default implementation ignores the configuration and simply calls Self::build

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§