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

User-facing APIs for object and object streams.

Implementations

Create a new operator.

Example

Read more backend init examples in examples.

use std::sync::Arc;

/// Example for initiating a fs backend.
use anyhow::Result;
use opendal::services::fs;
use opendal::services::fs::Builder;
use opendal::Accessor;
use opendal::Object;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
    // Create fs backend builder.
    let mut builder: Builder = fs::Backend::build();
    // Set the root for fs, all operations will happen under this root.
    //
    // NOTE: the root must be absolute path.
    builder.root("/tmp");
    // Build the `Accessor`.
    let accessor: Arc<dyn Accessor> = builder.finish().await?;

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

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

    Ok(())
}

Create a new layer.

Configure backoff for operators

This function only provided if feature retry is enabled.

Examples
use backon::ExponentialBackoff;
use opendal::Operator;

let op = Operator::new(accessor).with_backoff(ExponentialBackoff::default());
// All operations will be retried if the error is retryable
let _ = op.object("test_file").read();

Get metadata of underlying accessor.

Examples
use opendal::Operator;

let op = Operator::new(accessor);
let meta = op.metadata();

Create a new Object handle to take operations.

Check if this operator can work correctly.

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

use opendal::Operator;

let op = Operator::new(accessor);
op.check(".opendal").await?;

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

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.

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

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