pub trait Layer {
    fn layer(&self, inner: Arc<dyn Accessor>) -> Arc<dyn Accessor>;
}
Expand description

Layer is used to intercept the operations on the underlying storage.

Struct that implement this trait must accept input Arc<dyn Accessor> as inner, and returns a new Arc<dyn Accessor> as output.

All functions in Accessor requires &self, so it’s implementor’s responsibility to maintain the internal mutability. Please also keep in mind that Accessor requires Send and Sync.

Examples

use std::sync::Arc;
use opendal::{Accessor, Layer};

struct Trace {
    inner: Arc<dyn Accessor>,
}

impl Accessor for Trace {}

impl Layer for Trace {
    fn layer(&self, inner: Arc<dyn Accessor>) -> Arc<dyn Accessor> {
        Arc::new(Trace { inner })
    }
}

Required methods

Implementations on Foreign Types

Implementors