pub trait Accessor: Send + Sync + Debug + 'static {
Show 19 methods
fn inner(&self) -> Option<Arc<dyn Accessor>> { ... }
fn metadata(&self) -> AccessorMetadata { ... }
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: OpList
) -> Pin<Box<dyn Future<Output = Result<ObjectStreamer>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn presign(&self, path: &str, args: OpPresign) -> Result<PresignedRequest> { ... }
fn create_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: OpAbortMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
{ ... }
fn blocking_create(&self, path: &str, args: OpCreate) -> Result<()> { ... }
fn blocking_read(
&self,
path: &str,
args: OpRead
) -> Result<BlockingBytesReader> { ... }
fn blocking_write(
&self,
path: &str,
args: OpWrite,
r: BlockingBytesReader
) -> Result<u64> { ... }
fn blocking_stat(&self, path: &str, args: OpStat) -> Result<ObjectMetadata> { ... }
fn blocking_delete(&self, path: &str, args: OpDelete) -> Result<()> { ... }
fn blocking_list(&self, path: &str, args: OpList) -> Result<ObjectIterator> { ... }
}
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
Name | Capability |
---|---|
metadata | - |
create | - |
read | - |
write | - |
delete | - |
list | - |
presign | Presign |
create_multipart | Multipart |
write_multipart | Multipart |
complete_multipart | Multipart |
abort_multipart | Multipart |
blocking_create | Blocking |
blocking_read | Blocking |
blocking_write | Blocking |
blocking_delete | Blocking |
blocking_list | Blocking |
- 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.
- Path that ends with
- 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
std::io::ErrorKind::Unsupported
.
Provided Methods
sourcefn inner(&self) -> Option<Arc<dyn Accessor>>
fn inner(&self) -> Option<Arc<dyn Accessor>>
Return the inner accessor if there is one.
Behavior
- Service should not implement this method.
- Layers can implement this method to forward API call to inner accessor.
sourcefn metadata(&self) -> AccessorMetadata
fn metadata(&self) -> AccessorMetadata
Invoke the metadata
operation to get metadata of accessor.
sourcefn create<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpCreate
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpCreate
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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.
sourcefn read<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpRead
) -> Pin<Box<dyn Future<Output = Result<BytesReader>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpRead
) -> Pin<Box<dyn Future<Output = Result<BytesReader>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
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.
sourcefn write<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpWrite,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpWrite,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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.
sourcefn stat<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpStat
) -> Pin<Box<dyn Future<Output = Result<ObjectMetadata>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn stat<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpStat
) -> Pin<Box<dyn Future<Output = Result<ObjectMetadata>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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
andcontent_length
must be set.
sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpDelete
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpDelete
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
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.
sourcefn list<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpList
) -> Pin<Box<dyn Future<Output = Result<ObjectStreamer>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpList
) -> Pin<Box<dyn Future<Output = Result<ObjectStreamer>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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.
sourcefn presign(&self, path: &str, args: OpPresign) -> Result<PresignedRequest>
fn presign(&self, path: &str, args: OpPresign) -> Result<PresignedRequest>
Invoke the presign
operation on the specified path.
Behavior
- Require capability:
Presign
- This API is optional, return
std::io::ErrorKind::Unsupported
if not supported.
sourcefn create_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: 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
- Require capability:
Multipart
- This op returns a
upload_id
which is required to for following APIs.
sourcefn write_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: OpWriteMultipart,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<ObjectPart>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
sourcefn complete_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: 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.
Behavior
- Require capability:
Multipart
sourcefn abort_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: 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,
path: &'life1 str,
args: OpAbortMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
sourcefn blocking_create(&self, path: &str, args: OpCreate) -> Result<()>
fn blocking_create(&self, path: &str, args: OpCreate) -> Result<()>
Invoke the blocking_create
operation on the specified path.
This operation is the blocking version of Accessor::create
Behavior
- Require capability:
Blocking
sourcefn blocking_read(&self, path: &str, args: OpRead) -> Result<BlockingBytesReader>
fn blocking_read(&self, path: &str, args: OpRead) -> Result<BlockingBytesReader>
Invoke the blocking_read
operation on the specified path.
This operation is the blocking version of Accessor::read
Behavior
- Require capability:
Blocking
sourcefn blocking_write(
&self,
path: &str,
args: OpWrite,
r: BlockingBytesReader
) -> Result<u64>
fn blocking_write(
&self,
path: &str,
args: OpWrite,
r: BlockingBytesReader
) -> Result<u64>
Invoke the blocking_write
operation on the specified path.
This operation is the blocking version of Accessor::write
Behavior
- Require capability:
Blocking
sourcefn blocking_stat(&self, path: &str, args: OpStat) -> Result<ObjectMetadata>
fn blocking_stat(&self, path: &str, args: OpStat) -> Result<ObjectMetadata>
Invoke the blocking_stat
operation on the specified path.
This operation is the blocking version of Accessor::stat
Behavior
- Require capability:
Blocking
sourcefn blocking_delete(&self, path: &str, args: OpDelete) -> Result<()>
fn blocking_delete(&self, path: &str, args: OpDelete) -> Result<()>
Invoke the blocking_delete
operation on the specified path.
This operation is the blocking version of Accessor::delete
Behavior
- Require capability:
Blocking
sourcefn blocking_list(&self, path: &str, args: OpList) -> Result<ObjectIterator>
fn blocking_list(&self, path: &str, args: OpList) -> Result<ObjectIterator>
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
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>
.