pub trait ObjectClient {
type GetObjectResponse: GetObjectResponse<ClientError = Self::ClientError>;
type PutObjectRequest: PutObjectRequest<ClientError = Self::ClientError>;
type ClientError: Error + ProvideErrorMetadata + Send + Sync + 'static;
Show 13 methods
// Required methods
fn read_part_size(&self) -> usize;
fn write_part_size(&self) -> usize;
fn initial_read_window_size(&self) -> Option<usize>;
fn mem_usage_stats(&self) -> Option<BufferPoolUsageStats>;
async fn delete_object(
&self,
bucket: &str,
key: &str,
) -> ObjectClientResult<DeleteObjectResult, DeleteObjectError, Self::ClientError>;
async fn copy_object(
&self,
source_bucket: &str,
source_key: &str,
destination_bucket: &str,
destination_key: &str,
params: &CopyObjectParams,
) -> ObjectClientResult<CopyObjectResult, CopyObjectError, Self::ClientError>;
async fn get_object(
&self,
bucket: &str,
key: &str,
params: &GetObjectParams,
) -> ObjectClientResult<Self::GetObjectResponse, GetObjectError, Self::ClientError>;
async fn list_objects(
&self,
bucket: &str,
continuation_token: Option<&str>,
delimiter: &str,
max_keys: usize,
prefix: &str,
) -> ObjectClientResult<ListObjectsResult, ListObjectsError, Self::ClientError>;
async fn head_object(
&self,
bucket: &str,
key: &str,
params: &HeadObjectParams,
) -> ObjectClientResult<HeadObjectResult, HeadObjectError, Self::ClientError>;
async fn put_object(
&self,
bucket: &str,
key: &str,
params: &PutObjectParams,
) -> ObjectClientResult<Self::PutObjectRequest, PutObjectError, Self::ClientError>;
async fn put_object_single<'a>(
&self,
bucket: &str,
key: &str,
params: &PutObjectSingleParams,
contents: impl AsRef<[u8]> + Send + 'a,
) -> ObjectClientResult<PutObjectResult, PutObjectError, Self::ClientError>;
async fn get_object_attributes(
&self,
bucket: &str,
key: &str,
max_parts: Option<usize>,
part_number_marker: Option<usize>,
object_attributes: &[ObjectAttribute],
) -> ObjectClientResult<GetObjectAttributesResult, GetObjectAttributesError, Self::ClientError>;
async fn rename_object(
&self,
bucket: &str,
src_key: &str,
dest_key: &str,
params: &RenameObjectParams,
) -> ObjectClientResult<RenameObjectResult, RenameObjectError, Self::ClientError>;
}Expand description
A generic interface to S3-like object storage services.
This trait defines the common methods that all object services implement.
This is an async trait defined with the async-trait
crate, and so implementations of this trait must use the #[async_trait::async_trait]
attribute.
Required Associated Types§
type GetObjectResponse: GetObjectResponse<ClientError = Self::ClientError>
type PutObjectRequest: PutObjectRequest<ClientError = Self::ClientError>
type ClientError: Error + ProvideErrorMetadata + Send + Sync + 'static
Required Methods§
Sourcefn read_part_size(&self) -> usize
fn read_part_size(&self) -> usize
Query the part size this client uses for GET operations to the object store.
Sourcefn write_part_size(&self) -> usize
fn write_part_size(&self) -> usize
Query the part size this client uses for PUT operations to the object store.
Sourcefn initial_read_window_size(&self) -> Option<usize>
fn initial_read_window_size(&self) -> Option<usize>
Query the initial read window size this client uses for backpressure GetObject requests.
This can be None if backpressure is disabled.
Sourcefn mem_usage_stats(&self) -> Option<BufferPoolUsageStats>
fn mem_usage_stats(&self) -> Option<BufferPoolUsageStats>
Query current memory usage stats for the client. This can be None if the client
does not record the stats.
Sourceasync fn delete_object(
&self,
bucket: &str,
key: &str,
) -> ObjectClientResult<DeleteObjectResult, DeleteObjectError, Self::ClientError>
async fn delete_object( &self, bucket: &str, key: &str, ) -> ObjectClientResult<DeleteObjectResult, DeleteObjectError, Self::ClientError>
Delete a single object from the object store.
DeleteObject will succeed even if the object within the bucket does not exist.
Sourceasync fn copy_object(
&self,
source_bucket: &str,
source_key: &str,
destination_bucket: &str,
destination_key: &str,
params: &CopyObjectParams,
) -> ObjectClientResult<CopyObjectResult, CopyObjectError, Self::ClientError>
async fn copy_object( &self, source_bucket: &str, source_key: &str, destination_bucket: &str, destination_key: &str, params: &CopyObjectParams, ) -> ObjectClientResult<CopyObjectResult, CopyObjectError, Self::ClientError>
Create a copy of an existing object. Currently, this functionality has the following limitations:
- Supported only for copying between matching bucket types:
- Standard S3 to Standard S3 buckets.
- S3 Express to S3 Express buckets.
- Host header must use virtual host addressing style (path style is not supported) and both source and dest buckets must have dns compliant name.
- Only {bucket}/{key} format is supported for source and passing arn as source will not work.
- Source bucket is assumed to be in the same region as destination bucket.
Sourceasync fn get_object(
&self,
bucket: &str,
key: &str,
params: &GetObjectParams,
) -> ObjectClientResult<Self::GetObjectResponse, GetObjectError, Self::ClientError>
async fn get_object( &self, bucket: &str, key: &str, params: &GetObjectParams, ) -> ObjectClientResult<Self::GetObjectResponse, GetObjectError, Self::ClientError>
Get an object from the object store. Returns a stream of body parts of the object. Parts are guaranteed to be returned by the stream in order and contiguously.
Sourceasync fn list_objects(
&self,
bucket: &str,
continuation_token: Option<&str>,
delimiter: &str,
max_keys: usize,
prefix: &str,
) -> ObjectClientResult<ListObjectsResult, ListObjectsError, Self::ClientError>
async fn list_objects( &self, bucket: &str, continuation_token: Option<&str>, delimiter: &str, max_keys: usize, prefix: &str, ) -> ObjectClientResult<ListObjectsResult, ListObjectsError, Self::ClientError>
List the objects in a bucket under a given prefix
Sourceasync fn head_object(
&self,
bucket: &str,
key: &str,
params: &HeadObjectParams,
) -> ObjectClientResult<HeadObjectResult, HeadObjectError, Self::ClientError>
async fn head_object( &self, bucket: &str, key: &str, params: &HeadObjectParams, ) -> ObjectClientResult<HeadObjectResult, HeadObjectError, Self::ClientError>
Retrieve object metadata without retrieving the object contents
Sourceasync fn put_object(
&self,
bucket: &str,
key: &str,
params: &PutObjectParams,
) -> ObjectClientResult<Self::PutObjectRequest, PutObjectError, Self::ClientError>
async fn put_object( &self, bucket: &str, key: &str, params: &PutObjectParams, ) -> ObjectClientResult<Self::PutObjectRequest, PutObjectError, Self::ClientError>
Put an object into the object store. Returns a PutObjectRequest for callers to provide the content of the object.
Sourceasync fn put_object_single<'a>(
&self,
bucket: &str,
key: &str,
params: &PutObjectSingleParams,
contents: impl AsRef<[u8]> + Send + 'a,
) -> ObjectClientResult<PutObjectResult, PutObjectError, Self::ClientError>
async fn put_object_single<'a>( &self, bucket: &str, key: &str, params: &PutObjectSingleParams, contents: impl AsRef<[u8]> + Send + 'a, ) -> ObjectClientResult<PutObjectResult, PutObjectError, Self::ClientError>
Put an object into the object store.
Sourceasync fn get_object_attributes(
&self,
bucket: &str,
key: &str,
max_parts: Option<usize>,
part_number_marker: Option<usize>,
object_attributes: &[ObjectAttribute],
) -> ObjectClientResult<GetObjectAttributesResult, GetObjectAttributesError, Self::ClientError>
async fn get_object_attributes( &self, bucket: &str, key: &str, max_parts: Option<usize>, part_number_marker: Option<usize>, object_attributes: &[ObjectAttribute], ) -> ObjectClientResult<GetObjectAttributesResult, GetObjectAttributesError, Self::ClientError>
Retrieves all the metadata from an object without returning the object contents.
Sourceasync fn rename_object(
&self,
bucket: &str,
src_key: &str,
dest_key: &str,
params: &RenameObjectParams,
) -> ObjectClientResult<RenameObjectResult, RenameObjectError, Self::ClientError>
async fn rename_object( &self, bucket: &str, src_key: &str, dest_key: &str, params: &RenameObjectParams, ) -> ObjectClientResult<RenameObjectResult, RenameObjectError, Self::ClientError>
Rename an object from some source key to a destination key within the same bucket.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.