pub struct Operator { /* private fields */ }
Expand description

User-facing APIs for object and object streams.

Implementations

Create a new operator.

Examples

Read more backend init examples in examples.

#[tokio::main]
async fn main() -> Result<()> {
    // Create fs backend builder.
    let mut builder = fs::Builder::default();
    // Set the root for fs, all operations will happen under this root.
    //
    // NOTE: the root must be absolute path.
    builder.root("/tmp");

    // `Accessor` provides the low level APIs, we will use `Operator` normally.
    let op: Operator = Operator::new(builder.build()?);

    // Create an object handle to start operation on object.
    let _: Object = op.object("test_file");

    Ok(())
}

Create a new operator from iter.

Please refer different backends for detailed config options.

Behavior
  • All input key must be lower_case
  • Boolean values will be checked by its existences and non-empty value. on, yes, true, off, no, false will all be treated as true To disable a flag, please set value to empty.
Examples
#[tokio::main]
async fn main() -> Result<()> {
    let op: Operator = Operator::from_iter(
        Scheme::Fs,
        [("root".to_string(), "/tmp".to_string())].into_iter(),
    )?;

    // Create an object handle to start operation on object.
    let _: Object = op.object("test_file");

    Ok(())
}

Create a new operator from env.

Behavior
  • Environment keys are case-insensitive, they will be converted to lower case internally.
  • Environment values are case-sensitive, no sanity will be executed on them.
  • Boolean values will be checked by its existences and non-empty value. on, yes, true, off, no, false will all be treated as true To disable a flag, please set value to empty.
Examples

Setting environment:

export OPENDAL_FS_ROOT=/tmp

Please refer different backends for detailed config options.

#[tokio::main]
async fn main() -> Result<()> {
    // `Accessor` provides the low level APIs, we will use `Operator` normally.
    let op: Operator = Operator::from_env(Scheme::Fs)?;

    // Create an object handle to start operation on object.
    let _: Object = op.object("test_file");

    Ok(())
}

Create a new layer.

Examples

This examples needs feature retry enabled.

use opendal::Operator;
use opendal::Layer;

let accessor = fs::Backend::build().finish().await?;
let op = Operator::new(accessor).layer(new_layer);
// All operations will go through the new_layer
let _ = op.object("test_file").read();

Get metadata of underlying accessor.

Examples
use opendal::Operator;
use opendal::Scheme;

let op = Operator::from_env(Scheme::Fs)?;
let meta = op.metadata();

Create a new batch operator handle to take batch operations like walk and remove.

Create a new Object handle to take operations.

Check if this operator can work correctly.

We will send a list request to path and return any errors we met.

use opendal::Operator;
use opendal::Scheme;

let op = Operator::from_env(Scheme::Fs)?;
op.check().await?;

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Applies the Compat adapter by value. Read more
Applies the Compat adapter by shared reference. Read more
Applies the Compat adapter by mutable reference. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more