Trait MultiPartsUploader

Source
pub trait MultiPartsUploader:
    Sealed
    + MultiPartsUploaderWithCallbacks
    + Clone
    + Send
    + Sync
    + Debug {
    type HashAlgorithm: Digest + Send + 'static;
    type InitializedParts: InitializedParts + 'static;
    type UploadedPart: UploadedPart;
    type AsyncInitializedParts: InitializedParts + 'static;
    type AsyncUploadedPart: UploadedPart;

    // Required methods
    fn new<R: ResumableRecorder<HashAlgorithm = Self::HashAlgorithm> + 'static>(
        upload_manager: UploadManager,
        resumable_recorder: R,
    ) -> Self;
    fn upload_manager(&self) -> &UploadManager;
    fn initialize_parts<D: DataSource<Self::HashAlgorithm> + 'static>(
        &self,
        source: D,
        params: ObjectParams,
    ) -> ApiResult<Self::InitializedParts>;
    fn upload_part(
        &self,
        initialized: &Self::InitializedParts,
        data_partitioner_provider: &dyn DataPartitionProvider,
    ) -> ApiResult<Option<Self::UploadedPart>>;
    fn complete_parts(
        &self,
        initialized: &Self::InitializedParts,
        parts: &[Self::UploadedPart],
    ) -> ApiResult<Value>;
    fn reinitialize_parts(
        &self,
        initialized: &mut Self::InitializedParts,
        options: ReinitializeOptions,
    ) -> ApiResult<()>;
    fn try_to_resume_parts<D: DataSource<Self::HashAlgorithm> + 'static>(
        &self,
        source: D,
        params: ObjectParams,
    ) -> Option<Self::InitializedParts>;
    fn async_initialize_parts<D: AsyncDataSource<Self::HashAlgorithm> + 'static>(
        &self,
        source: D,
        params: ObjectParams,
    ) -> BoxFuture<'_, ApiResult<Self::AsyncInitializedParts>>;
    fn async_upload_part<'r>(
        &'r self,
        initialized: &'r Self::AsyncInitializedParts,
        data_partitioner_provider: &'r dyn DataPartitionProvider,
    ) -> BoxFuture<'r, ApiResult<Option<Self::AsyncUploadedPart>>>;
    fn async_complete_parts<'r>(
        &'r self,
        initialized: &'r Self::AsyncInitializedParts,
        parts: &'r [Self::AsyncUploadedPart],
    ) -> BoxFuture<'r, ApiResult<Value>>;
    fn async_reinitialize_parts<'r>(
        &'r self,
        initialized: &'r mut Self::AsyncInitializedParts,
        options: ReinitializeOptions,
    ) -> BoxFuture<'r, ApiResult<()>>;
    fn try_to_async_resume_parts<D: AsyncDataSource<Self::HashAlgorithm> + 'static>(
        &self,
        source: D,
        params: ObjectParams,
    ) -> BoxFuture<'_, Option<Self::AsyncInitializedParts>>;
}
Expand description

分片上传器接口

将数据源通过多个分片的方式逐一上传,适合数据量较大的数据源,可以提供断点恢复的能力。

Required Associated Types§

Source

type HashAlgorithm: Digest + Send + 'static

数据源 KEY 的哈希算法

Source

type InitializedParts: InitializedParts + 'static

初始化的分片信息

Source

type UploadedPart: UploadedPart

已经上传的分片信息

Source

type AsyncInitializedParts: InitializedParts + 'static

Available on crate feature async only.

初始化的异步分片信息

Source

type AsyncUploadedPart: UploadedPart

Available on crate feature async only.

已经上传的异步分片信息

Required Methods§

Source

fn new<R: ResumableRecorder<HashAlgorithm = Self::HashAlgorithm> + 'static>( upload_manager: UploadManager, resumable_recorder: R, ) -> Self

创建分片上传器

Source

fn upload_manager(&self) -> &UploadManager

获取初始化使用的上传管理器

Source

fn initialize_parts<D: DataSource<Self::HashAlgorithm> + 'static>( &self, source: D, params: ObjectParams, ) -> ApiResult<Self::InitializedParts>

初始化分片信息

该步骤只负责初始化分片,但不实际上传数据,如果提供了有效的断点续传记录器,则可以尝试在这一步找到记录。

该方法的异步版本为 Self::async_initialize_parts

Source

fn upload_part( &self, initialized: &Self::InitializedParts, data_partitioner_provider: &dyn DataPartitionProvider, ) -> ApiResult<Option<Self::UploadedPart>>

上传分片

实际上传的分片大小由提供的分片大小提供者获取。

如果返回 [Ok(None)] 则表示已经没有更多分片可以上传。

该方法的异步版本为 Self::async_upload_part

Source

fn complete_parts( &self, initialized: &Self::InitializedParts, parts: &[Self::UploadedPart], ) -> ApiResult<Value>

完成分片上传

在这步成功返回后,对象即可被读取。

该方法的异步版本为 Self::async_complete_parts

Source

fn reinitialize_parts( &self, initialized: &mut Self::InitializedParts, options: ReinitializeOptions, ) -> ApiResult<()>

重新初始化分片信息

该步骤负责将先前已经初始化过的分片信息全部重置,清空断点续传记录器中的记录,之后从头上传整个文件

该方法的异步版本为 Self::async_reinitialize_parts

Source

fn try_to_resume_parts<D: DataSource<Self::HashAlgorithm> + 'static>( &self, source: D, params: ObjectParams, ) -> Option<Self::InitializedParts>

尝试恢复记录

如果提供了有效的断点续传记录器,该方法可以尝试在找到记录,如果找不到记录,或记录无法读取,则返回 None

该方法的异步版本为 Self::try_to_async_resume_parts

Source

fn async_initialize_parts<D: AsyncDataSource<Self::HashAlgorithm> + 'static>( &self, source: D, params: ObjectParams, ) -> BoxFuture<'_, ApiResult<Self::AsyncInitializedParts>>

Available on crate feature async only.

异步初始化分片信息

该步骤只负责初始化分片,但不实际上传数据,如果提供了有效的断点续传记录器,则可以尝试在这一步找到记录。

Source

fn async_upload_part<'r>( &'r self, initialized: &'r Self::AsyncInitializedParts, data_partitioner_provider: &'r dyn DataPartitionProvider, ) -> BoxFuture<'r, ApiResult<Option<Self::AsyncUploadedPart>>>

Available on crate feature async only.

异步上传分片

实际上传的分片大小由提供的分片大小提供者获取。

如果返回 [Ok(None)] 则表示已经没有更多分片可以上传。

Source

fn async_complete_parts<'r>( &'r self, initialized: &'r Self::AsyncInitializedParts, parts: &'r [Self::AsyncUploadedPart], ) -> BoxFuture<'r, ApiResult<Value>>

Available on crate feature async only.

异步完成分片上传

在这步成功返回后,对象即可被读取。

Source

fn async_reinitialize_parts<'r>( &'r self, initialized: &'r mut Self::AsyncInitializedParts, options: ReinitializeOptions, ) -> BoxFuture<'r, ApiResult<()>>

Available on crate feature async only.

异步重新初始化分片信息

该步骤负责将先前已经初始化过的分片信息全部重置,清空断点续传记录器中的记录,之后从头上传整个文件

Source

fn try_to_async_resume_parts<D: AsyncDataSource<Self::HashAlgorithm> + 'static>( &self, source: D, params: ObjectParams, ) -> BoxFuture<'_, Option<Self::AsyncInitializedParts>>

Available on crate feature async only.

异步尝试恢复记录

如果提供了有效的断点续传记录器,该方法可以尝试在找到记录,如果找不到记录,或记录无法读取,则返回 None

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.

Implementors§