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§
Sourcetype Iter
type Iter
The BackendIter returned from iter() below.
Sourcetype Config
type Config
The configuration type constructing BackendSelection
Required Methods§
Sourcefn build(backends: &BTreeSet<Backend>) -> Self
fn build(backends: &BTreeSet<Backend>) -> Self
The function to create a BackendSelection implementation.
Sourcefn iter(self: &Arc<Self>, key: &[u8]) -> Self::Iterwhere
Self::Iter: BackendIter,
fn iter(self: &Arc<Self>, key: &[u8]) -> Self::Iterwhere
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§
Sourcefn build_with_config(
backends: &BTreeSet<Backend>,
_config: &Self::Config,
) -> Self
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.