Trait opendal::raw::Accessor

source ·
pub trait Accessor: Send + Sync + Debug + Unpin + 'static {
    type Reader: Read;
    type BlockingReader: BlockingRead;
    type Writer: Write;
    type BlockingWriter: BlockingWrite;
    type Pager: Page;
    type BlockingPager: BlockingPage;

Show 17 methods // Required method fn info(&self) -> AccessorInfo; // Provided methods 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 ) -> Pin<Box<dyn Future<Output = Result<(RpWrite, Self::Writer)>> + 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, Self::Pager)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn scan<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, args: OpScan ) -> Pin<Box<dyn Future<Output = Result<(RpScan, Self::Pager)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn presign(&self, path: &str, args: OpPresign) -> Result<RpPresign> { ... } fn batch<'life0, 'async_trait>( &'life0 self, args: OpBatch ) -> Pin<Box<dyn Future<Output = Result<RpBatch>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: '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 ) -> Result<(RpWrite, Self::BlockingWriter)> { ... } 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, Self::BlockingPager)> { ... } fn blocking_scan( &self, path: &str, args: OpScan ) -> Result<(RpScan, Self::BlockingPager)> { ... }
}
Expand description

Underlying trait of all backends for implementors.

Note

Visit internals for more tutorials.

Operations

  • 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.
    • Services can implement them based on services capabilities.
    • The default implementation should return ErrorKind::Unsupported.

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.

source

type Writer: Write

Reader is the associated writer the could return in write operation.

source

type BlockingWriter: BlockingWrite

BlockingWriter is the associated writer the could return in blocking_write operation.

source

type Pager: Page

Pager is the associated page that return in list or scan operation.

source

type BlockingPager: BlockingPage

BlockingPager is the associated pager that could return in blocking_list or scan operation.

Required Methods§

source

fn info(&self) -> AccessorInfo

Invoke the info operation to get metadata of accessor.

Notes

This function is required to be implemented.

By returning AccessorInfo, underlying services can declare some useful information about it self.

  • scheme: declare the scheme of backend.
  • capabilities: declare the capabilities of current backend.
  • hints: declare the hints of current backend

Provided Methods§

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

Require AccessorCapability::Write

Behavior
  • Input path MUST match with EntryMode, DON’T NEED to check 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 Reader if operate successful.

Require AccessorCapability::Read

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

fn write<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, args: OpWrite ) -> Pin<Box<dyn Future<Output = Result<(RpWrite, Self::Writer)>> + 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.

Require AccessorCapability::Write

Behavior
  • Input path MUST be file path, DON’T NEED to check 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.

Require AccessorCapability::Read

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.

Require AccessorCapability::Write

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, Self::Pager)>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Invoke the list operation on the specified path.

Require AccessorCapability::List

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

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

Invoke the scan operation on the specified path.

Require AccessorCapability::Scan

source

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

Invoke the presign operation on the specified path.

Require AccessorCapability::Presign

Behavior
source

fn batch<'life0, 'async_trait>( &'life0 self, args: OpBatch ) -> Pin<Box<dyn Future<Output = Result<RpBatch>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Invoke the batch operations.

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

Require AccessorCapability::Write and AccessorCapability::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

Require AccessorCapability::Read and AccessorCapability::Blocking

source

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

Invoke the blocking_write operation on the specified path.

This operation is the blocking version of Accessor::write

Require AccessorCapability::Write and AccessorCapability::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

Require AccessorCapability::Read and AccessorCapability::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

Require AccessorCapability::Write and AccessorCapability::Blocking

source

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

Invoke the blocking_list operation on the specified path.

This operation is the blocking version of Accessor::list

Require AccessorCapability::List and AccessorCapability::Blocking

Behavior
  • List non-exist dir should return Empty.
source

fn blocking_scan( &self, path: &str, args: OpScan ) -> Result<(RpScan, Self::BlockingPager)>

Invoke the blocking_scan operation on the specified path.

Require AccessorCapability::Scan and AccessorCapability::Blocking

Implementations on Foreign Types§

source§

impl Accessor for ()

Dummy implementation of accessor.

source§

impl<T: Accessor + ?Sized> 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

§

type Writer = <T as Accessor>::Writer

§

type BlockingWriter = <T as Accessor>::BlockingWriter

§

type Pager = <T as Accessor>::Pager

§

type BlockingPager = <T as Accessor>::BlockingPager

source§

fn info(&self) -> AccessorInfo

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 ) -> Pin<Box<dyn Future<Output = Result<(RpWrite, Self::Writer)>> + 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, Self::Pager)>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

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

source§

fn batch<'life0, 'async_trait>( &'life0 self, args: OpBatch ) -> Pin<Box<dyn Future<Output = Result<RpBatch>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

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

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 ) -> Result<(RpWrite, Self::BlockingWriter)>

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, Self::BlockingPager)>

source§

fn blocking_scan( &self, path: &str, args: OpScan ) -> Result<(RpScan, Self::BlockingPager)>

Implementors§