Trait opendal::raw::Accessor

source ·
pub trait Accessor: Send + Sync + Debug + Unpin + 'static {
    type Reader: Read;
    type BlockingReader: BlockingRead;

Show 18 methods fn metadata(&self) -> AccessorMetadata { ... } fn create<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        args: OpCreate
    ) -> Pin<Box<dyn Future<Output = Result<RpCreate>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn read<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        args: OpRead
    ) -> Pin<Box<dyn Future<Output = Result<(RpRead, Self::Reader)>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn write<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        args: OpWrite,
        r: Reader
    ) -> Pin<Box<dyn Future<Output = Result<RpWrite>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn stat<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        args: OpStat
    ) -> Pin<Box<dyn Future<Output = Result<RpStat>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        args: OpDelete
    ) -> Pin<Box<dyn Future<Output = Result<RpDelete>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        args: OpList
    ) -> Pin<Box<dyn Future<Output = Result<(RpList, ObjectPager)>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn presign(&self, path: &str, args: OpPresign) -> Result<RpPresign> { ... } fn create_multipart<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        args: OpCreateMultipart
    ) -> Pin<Box<dyn Future<Output = Result<RpCreateMultipart>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn write_multipart<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        args: OpWriteMultipart,
        r: Reader
    ) -> Pin<Box<dyn Future<Output = Result<RpWriteMultipart>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn complete_multipart<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        args: OpCompleteMultipart
    ) -> Pin<Box<dyn Future<Output = Result<RpCompleteMultipart>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn abort_multipart<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        args: OpAbortMultipart
    ) -> Pin<Box<dyn Future<Output = Result<RpAbortMultipart>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn blocking_create(&self, path: &str, args: OpCreate) -> Result<RpCreate> { ... } fn blocking_read(
        &self,
        path: &str,
        args: OpRead
    ) -> Result<(RpRead, Self::BlockingReader)> { ... } fn blocking_write(
        &self,
        path: &str,
        args: OpWrite,
        r: BlockingReader
    ) -> Result<RpWrite> { ... } fn blocking_stat(&self, path: &str, args: OpStat) -> Result<RpStat> { ... } fn blocking_delete(&self, path: &str, args: OpDelete) -> Result<RpDelete> { ... } fn blocking_list(
        &self,
        path: &str,
        args: OpList
    ) -> Result<(RpList, BlockingObjectPager)> { ... }
}
Expand description

Underlying trait of all backends for implementors.

Note

Only service implementor should care about this trait, users need to use Operator instead.

Operations

NameCapability
metadata-
create-
read-
write-
delete-
list-
presignPresign
create_multipartMultipart
write_multipartMultipart
complete_multipartMultipart
abort_multipartMultipart
blocking_createBlocking
blocking_readBlocking
blocking_writeBlocking
blocking_deleteBlocking
blocking_listBlocking
  • Path in args will all be normalized into the same style, services should handle them based on services’ requirement.
    • Path that ends with / means it’s Dir, otherwise, it’s File.
    • Root dir is /
    • Path will never be empty.
  • Operations without capability requirement like metadata, create are basic operations.
    • All services must implement them.
    • Use unimplemented!() if not implemented or can’t implement.
  • Operations with capability requirement like presign are optional operations.

Required Associated Types§

source

type Reader: Read

Reader is the associated reader the could return in read operation.

source

type BlockingReader: BlockingRead

BlockingReader is the associated reader that could return in blocking_read operation.

Provided Methods§

source

fn metadata(&self) -> AccessorMetadata

Invoke the metadata operation to get metadata of accessor.

source

fn create<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpCreate
) -> Pin<Box<dyn Future<Output = Result<RpCreate>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Invoke the create operation on the specified path

Behavior
  • Input path MUST match with ObjectMode, DON’T NEED to check object mode.
  • Create on existing dir SHOULD succeed.
  • Create on existing file SHOULD overwrite and truncate.
source

fn read<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpRead
) -> Pin<Box<dyn Future<Output = Result<(RpRead, Self::Reader)>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Invoke the read operation on the specified path, returns a ObjectReader if operate successful.

Behavior
  • Input path MUST be file path, DON’T NEED to check object mode.
  • The returning contnet length may be smaller than the range specifed.
source

fn write<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpWrite,
    r: Reader
) -> Pin<Box<dyn Future<Output = Result<RpWrite>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Invoke the write operation on the specified path, returns a written size if operate successful.

Behavior
  • Input path MUST be file path, DON’T NEED to check object mode.
source

fn stat<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpStat
) -> Pin<Box<dyn Future<Output = Result<RpStat>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Invoke the stat operation on the specified path.

Behavior
  • stat empty path means stat backend’s root path.
  • stat a path endswith “/” means stating a dir.
  • mode and content_length must be set.
source

fn delete<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpDelete
) -> Pin<Box<dyn Future<Output = Result<RpDelete>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Invoke the delete operation on the specified path.

Behavior
  • delete is an idempotent operation, it’s safe to call Delete on the same path multiple times.
  • delete SHOULD return Ok(()) if the path is deleted successfully or not exist.
source

fn list<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpList
) -> Pin<Box<dyn Future<Output = Result<(RpList, ObjectPager)>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Invoke the list operation on the specified path.

Behavior
  • Input path MUST be dir path, DON’T NEED to check object mode.
  • List non-exist dir should return Empty.
source

fn presign(&self, path: &str, args: OpPresign) -> Result<RpPresign>

Invoke the presign operation on the specified path.

Behavior
source

fn create_multipart<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpCreateMultipart
) -> Pin<Box<dyn Future<Output = Result<RpCreateMultipart>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Invoke the create_multipart operation on the specified path.

Behavior
  • Require capability: Multipart
  • This op returns a upload_id which is required to for following APIs.
source

fn write_multipart<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpWriteMultipart,
    r: Reader
) -> Pin<Box<dyn Future<Output = Result<RpWriteMultipart>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Invoke the write_multipart operation on the specified path.

Behavior
  • Require capability: Multipart
source

fn complete_multipart<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpCompleteMultipart
) -> Pin<Box<dyn Future<Output = Result<RpCompleteMultipart>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Invoke the complete_multipart operation on the specified path.

Behavior
  • Require capability: Multipart
source

fn abort_multipart<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpAbortMultipart
) -> Pin<Box<dyn Future<Output = Result<RpAbortMultipart>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Invoke the abort_multipart operation on the specified path.

Behavior
  • Require capability: Multipart
source

fn blocking_create(&self, path: &str, args: OpCreate) -> Result<RpCreate>

Invoke the blocking_create operation on the specified path.

This operation is the blocking version of Accessor::create

Behavior
  • Require capability: Blocking
source

fn blocking_read(
    &self,
    path: &str,
    args: OpRead
) -> Result<(RpRead, Self::BlockingReader)>

Invoke the blocking_read operation on the specified path.

This operation is the blocking version of Accessor::read

Behavior
  • Require capability: Blocking
source

fn blocking_write(
    &self,
    path: &str,
    args: OpWrite,
    r: BlockingReader
) -> Result<RpWrite>

Invoke the blocking_write operation on the specified path.

This operation is the blocking version of Accessor::write

Behavior
  • Require capability: Blocking
source

fn blocking_stat(&self, path: &str, args: OpStat) -> Result<RpStat>

Invoke the blocking_stat operation on the specified path.

This operation is the blocking version of Accessor::stat

Behavior
  • Require capability: Blocking
source

fn blocking_delete(&self, path: &str, args: OpDelete) -> Result<RpDelete>

Invoke the blocking_delete operation on the specified path.

This operation is the blocking version of Accessor::delete

Behavior
  • Require capability: Blocking
source

fn blocking_list(
    &self,
    path: &str,
    args: OpList
) -> Result<(RpList, BlockingObjectPager)>

Invoke the blocking_list operation on the specified path.

This operation is the blocking version of Accessor::list

Behavior
  • Require capability: Blocking
  • List non-exist dir should return Empty.

Implementations on Foreign Types§

source§

impl<T: Accessor> Accessor for Arc<T>

All functions in Accessor only requires &self, so it’s safe to implement Accessor for Arc<dyn Accessor>.

§

type Reader = <T as Accessor>::Reader

§

type BlockingReader = <T as Accessor>::BlockingReader

source§

fn metadata(&self) -> AccessorMetadata

source§

fn create<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpCreate
) -> Pin<Box<dyn Future<Output = Result<RpCreate>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

source§

fn read<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpRead
) -> Pin<Box<dyn Future<Output = Result<(RpRead, Self::Reader)>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

source§

fn write<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpWrite,
    r: Reader
) -> Pin<Box<dyn Future<Output = Result<RpWrite>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

source§

fn stat<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpStat
) -> Pin<Box<dyn Future<Output = Result<RpStat>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

source§

fn delete<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpDelete
) -> Pin<Box<dyn Future<Output = Result<RpDelete>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

source§

fn list<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpList
) -> Pin<Box<dyn Future<Output = Result<(RpList, ObjectPager)>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

source§

fn presign(&self, path: &str, args: OpPresign) -> Result<RpPresign>

source§

fn create_multipart<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpCreateMultipart
) -> Pin<Box<dyn Future<Output = Result<RpCreateMultipart>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

source§

fn write_multipart<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpWriteMultipart,
    r: Reader
) -> Pin<Box<dyn Future<Output = Result<RpWriteMultipart>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

source§

fn complete_multipart<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpCompleteMultipart
) -> Pin<Box<dyn Future<Output = Result<RpCompleteMultipart>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

source§

fn abort_multipart<'life0, 'life1, 'async_trait>(
    &'life0 self,
    path: &'life1 str,
    args: OpAbortMultipart
) -> Pin<Box<dyn Future<Output = Result<RpAbortMultipart>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

source§

fn blocking_create(&self, path: &str, args: OpCreate) -> Result<RpCreate>

source§

fn blocking_read(
    &self,
    path: &str,
    args: OpRead
) -> Result<(RpRead, Self::BlockingReader)>

source§

fn blocking_write(
    &self,
    path: &str,
    args: OpWrite,
    r: BlockingReader
) -> Result<RpWrite>

source§

fn blocking_stat(&self, path: &str, args: OpStat) -> Result<RpStat>

source§

fn blocking_delete(&self, path: &str, args: OpDelete) -> Result<RpDelete>

source§

fn blocking_list(
    &self,
    path: &str,
    args: OpList
) -> Result<(RpList, BlockingObjectPager)>

Implementors§