Trait Configurator
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, Error> { ... }
fn from_iter(
iter: impl IntoIterator<Item = (String, String)>,
) -> Result<Self, Error> { ... }
}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§
Required Methods§
fn into_builder(self) -> Self::Builder
fn into_builder(self) -> Self::Builder
Convert this configuration into a service builder.
Provided Methods§
fn from_uri(_uri: &OperatorUri) -> Result<Self, Error>
fn from_uri(_uri: &OperatorUri) -> Result<Self, Error>
Build configuration from a parsed URI with merged options.
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.