Trait ObjectClient

Source
pub trait ObjectClient {
    type GetObjectResponse: GetObjectResponse<ClientError = Self::ClientError>;
    type PutObjectRequest: PutObjectRequest<ClientError = Self::ClientError>;
    type ClientError: Error + ProvideErrorMetadata + Send + Sync + 'static;

    // Required methods
    fn read_part_size(&self) -> Option<usize>;
    fn write_part_size(&self) -> Option<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>;
}
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§

Required Methods§

Source

fn read_part_size(&self) -> Option<usize>

Query the part size this client uses for GET operations to the object store. This can be None if the client does not do multi-part operations.

Source

fn write_part_size(&self) -> Option<usize>

Query the part size this client uses for PUT operations to the object store. This can be None if the client does not do multi-part operations.

Source

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.

Source

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.

Source

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.

Source

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.
Source

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.

Source

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

Source

async fn head_object( &self, bucket: &str, key: &str, params: &HeadObjectParams, ) -> ObjectClientResult<HeadObjectResult, HeadObjectError, Self::ClientError>

Retrieve object metadata without retrieving the object contents

Source

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.

Source

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.

Source

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.

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.

Implementations on Foreign Types§

Source§

impl<T: ObjectClient + ?Sized> ObjectClient for Arc<T>

Source§

type GetObjectResponse = <T as ObjectClient>::GetObjectResponse

Source§

type PutObjectRequest = <T as ObjectClient>::PutObjectRequest

Source§

type ClientError = <T as ObjectClient>::ClientError

Source§

fn read_part_size(&self) -> Option<usize>

Source§

fn write_part_size(&self) -> Option<usize>

Source§

fn initial_read_window_size(&self) -> Option<usize>

Source§

fn mem_usage_stats(&self) -> Option<BufferPoolUsageStats>

Source§

async fn delete_object( &self, bucket: &str, key: &str, ) -> ObjectClientResult<DeleteObjectResult, DeleteObjectError, Self::ClientError>

Source§

async fn copy_object( &self, source_bucket: &str, source_key: &str, destination_bucket: &str, destination_key: &str, params: &CopyObjectParams, ) -> ObjectClientResult<CopyObjectResult, CopyObjectError, Self::ClientError>

Source§

async fn get_object( &self, bucket: &str, key: &str, params: &GetObjectParams, ) -> ObjectClientResult<Self::GetObjectResponse, GetObjectError, Self::ClientError>

Source§

async fn list_objects( &self, bucket: &str, continuation_token: Option<&str>, delimiter: &str, max_keys: usize, prefix: &str, ) -> ObjectClientResult<ListObjectsResult, ListObjectsError, Self::ClientError>

Source§

async fn head_object( &self, bucket: &str, key: &str, params: &HeadObjectParams, ) -> ObjectClientResult<HeadObjectResult, HeadObjectError, Self::ClientError>

Source§

async fn put_object( &self, bucket: &str, key: &str, params: &PutObjectParams, ) -> ObjectClientResult<Self::PutObjectRequest, PutObjectError, Self::ClientError>

Source§

async fn put_object_single<'a>( &self, bucket: &str, key: &str, params: &PutObjectSingleParams, contents: impl AsRef<[u8]> + Send + 'a, ) -> ObjectClientResult<PutObjectResult, PutObjectError, Self::ClientError>

Source§

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>

Implementors§