pub trait Accessor: Send + Sync + Debug {
fn metadata(&self) -> AccessorMetadata { ... }
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpCreate
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpRead
) -> Pin<Box<dyn Future<Output = Result<BytesReader>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpWrite,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn stat<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpStat
) -> Pin<Box<dyn Future<Output = Result<ObjectMetadata>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpDelete
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpList
) -> Pin<Box<dyn Future<Output = Result<DirStreamer>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn presign(&self, args: &OpPresign) -> Result<PresignedRequest> { ... }
fn create_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpCreateMultipart
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn write_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpWriteMultipart,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<ObjectPart>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn complete_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpCompleteMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn abort_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpAbortMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
}
Expand description
Underlying trait of all backends for implementors.
Note to users
Only service implementor should care about this trait, users need to
use Operator
instead.
Note to services
- Path in args will all be normalized into the same style, services should handle them based on services’ requirement.
metadata
,create
,read
,write
,stat
,delete
andlist
are basic functions while required to be implemented, useunimplemented!()
if not implemented or can’t implement.- Other APIs are optional and should be recorded in
AccessorCapability
. Returnstd::io::ErrorKind::Unsupported
if not supported.
Provided Methods
sourcefn metadata(&self) -> AccessorMetadata
fn metadata(&self) -> AccessorMetadata
Required APIs.
Invoke the metadata
operation to get metadata of accessor.
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.
Invoke the read
operation on the specified path, returns a
BytesReader
if operate successful.
Behavior
- Input path MUST be file path, DON’T NEED to check object mode.
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.
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.
Invoke the delete
operation on the specified path.
Behavior
delete
is an idempotent operation, it’s safe to callDelete
on the same path multiple times.delete
SHOULD returnOk(())
if the path is deleted successfully or not exist.
Invoke the list
operation on the specified path.
Behavior
- Input path MUST be dir path, DON’T NEED to check object mode.
sourcefn presign(&self, args: &OpPresign) -> Result<PresignedRequest>
fn presign(&self, args: &OpPresign) -> Result<PresignedRequest>
Optional APIs (Capabilities)
Invoke the presign
operation on the specified path.
Behavior
- This API is optional, return
std::io::ErrorKind::Unsupported
if not supported.
sourcefn create_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpCreateMultipart
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn create_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpCreateMultipart
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the create_multipart
operation on the specified path.
Behavior
- This op returns a
upload_id
which is required to for following APIs.
sourcefn write_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpWriteMultipart,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<ObjectPart>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn write_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpWriteMultipart,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<ObjectPart>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the write_multipart
operation on the specified path.
sourcefn complete_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpCompleteMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn complete_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpCompleteMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the complete_multipart
operation on the specified path.
sourcefn abort_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpAbortMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn abort_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 OpAbortMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the abort_multipart
operation on the specified path.
Implementations on Foreign Types
sourceimpl<T: Accessor> Accessor for Arc<T>
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>
.