Skip to main content

Configurator

Trait Configurator 

Source
pub trait Configurator:
    Serialize
    + DeserializeOwned
    + Debug
    + 'static {
    type Builder: Builder;

    // Required method
    fn into_builder(self) -> Self::Builder;

    // Provided methods
    fn from_uri(_uri: &OperatorUri) -> Result<Self> { ... }
    fn from_iter(
        iter: impl IntoIterator<Item = (String, String)>,
    ) -> Result<Self> { ... }
}
Expand description

OpenDAL uses Configurator to configure a service.

This trait allows the developer to define a configuration struct that can:

  • Deserialize from an iterator such as a hash map or vector.
  • Convert into a service builder and then build a concrete service.

Users can usually use the Operator API instead of importing and using Configurator directly. For example:

use std::collections::HashMap;

use opendal_core::services::MemoryConfig;
use opendal_core::Operator;
async fn test() -> Result<()> {
    let mut cfg = MemoryConfig::default();
    cfg.root = Some("/".to_string());

    // Build an `Operator` to start operating the storage.
    let op: Operator = Operator::from_config(cfg)?;

    Ok(())
}

Required Associated Types§

Source

type Builder: Builder

Associated builder for this configuration.

Required Methods§

Source

fn into_builder(self) -> Self::Builder

Convert this configuration into a service builder.

Provided Methods§

Source

fn from_uri(_uri: &OperatorUri) -> Result<Self>

Build configuration from a parsed URI with merged options.

Source

fn from_iter(iter: impl IntoIterator<Item = (String, String)>) -> Result<Self>

Deserialize from an iterator.

OpenDAL provides this method; service developers should not need to override it.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Configurator for ()

Implementors§