Trait Builder

Source
pub trait Builder: Default + 'static {
    type Config: Configurator;

    const SCHEME: Scheme;

    // Required method
    fn build(self) -> Result<impl Access>;
}
Expand description

Builder is used to set up underlying services.

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

  • build a service via builder style API.
  • configure in-memory options like http_client or customized_credential_load.

Usually, users don’t need to use or import this trait directly, they can use Operator API instead.

For example:

use opendal::services::Fs;
use opendal::Operator;
async fn test() -> Result<()> {
    // Create fs backend builder.
    let mut builder = Fs::default().root("/tmp");

    // Build an `Operator` to start operating the storage.
    let op: Operator = Operator::new(builder)?.finish();

    Ok(())
}

Required Associated Constants§

Source

const SCHEME: Scheme

Associated scheme for this builder. It indicates what underlying service is.

Required Associated Types§

Source

type Config: Configurator

Associated configuration for this builder.

Required Methods§

Source

fn build(self) -> Result<impl Access>

Consume the accessor builder to build a service.

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.

Implementations on Foreign Types§

Source§

impl Builder for ()

Dummy implementation of builder

Implementors§