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>(upload_manager: UploadManager, resumable_recorder: R) -> Self
where R: ResumableRecorder<HashAlgorithm = Self::HashAlgorithm> + 'static;
fn upload_manager(&self) -> &UploadManager;
fn initialize_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Result<Self::InitializedParts, Error>
where D: DataSource<Self::HashAlgorithm> + 'static;
fn upload_part(
&self,
initialized: &Self::InitializedParts,
data_partitioner_provider: &dyn DataPartitionProvider,
) -> Result<Option<Self::UploadedPart>, Error>;
fn complete_parts(
&self,
initialized: &Self::InitializedParts,
parts: &[Self::UploadedPart],
) -> Result<Value, Error>;
fn reinitialize_parts(
&self,
initialized: &mut Self::InitializedParts,
options: ReinitializeOptions,
) -> Result<(), Error>;
fn try_to_resume_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Option<Self::InitializedParts>
where D: DataSource<Self::HashAlgorithm> + 'static;
fn async_initialize_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Pin<Box<dyn Future<Output = Result<Self::AsyncInitializedParts, Error>> + Send + '_>>
where D: AsyncDataSource<Self::HashAlgorithm> + 'static;
fn async_upload_part<'r>(
&'r self,
initialized: &'r Self::AsyncInitializedParts,
data_partitioner_provider: &'r dyn DataPartitionProvider,
) -> Pin<Box<dyn Future<Output = Result<Option<Self::AsyncUploadedPart>, Error>> + Send + 'r>>;
fn async_complete_parts<'r>(
&'r self,
initialized: &'r Self::AsyncInitializedParts,
parts: &'r [Self::AsyncUploadedPart],
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + 'r>>;
fn async_reinitialize_parts<'r>(
&'r self,
initialized: &'r mut Self::AsyncInitializedParts,
options: ReinitializeOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'r>>;
fn try_to_async_resume_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Pin<Box<dyn Future<Output = Option<Self::AsyncInitializedParts>> + Send + '_>>
where D: AsyncDataSource<Self::HashAlgorithm> + 'static;
}
Expand description
分片上传器接口
将数据源通过多个分片的方式逐一上传,适合数据量较大的数据源,可以提供断点恢复的能力。
Required Associated Types§
Sourcetype HashAlgorithm: Digest + Send + 'static
type HashAlgorithm: Digest + Send + 'static
数据源 KEY 的哈希算法
Sourcetype InitializedParts: InitializedParts + 'static
type InitializedParts: InitializedParts + 'static
初始化的分片信息
Sourcetype UploadedPart: UploadedPart
type UploadedPart: UploadedPart
已经上传的分片信息
Sourcetype AsyncInitializedParts: InitializedParts + 'static
type AsyncInitializedParts: InitializedParts + 'static
初始化的异步分片信息
Sourcetype AsyncUploadedPart: UploadedPart
type AsyncUploadedPart: UploadedPart
已经上传的异步分片信息
Required Methods§
Sourcefn new<R>(upload_manager: UploadManager, resumable_recorder: R) -> Selfwhere
R: ResumableRecorder<HashAlgorithm = Self::HashAlgorithm> + 'static,
fn new<R>(upload_manager: UploadManager, resumable_recorder: R) -> Selfwhere
R: ResumableRecorder<HashAlgorithm = Self::HashAlgorithm> + 'static,
创建分片上传器
Sourcefn upload_manager(&self) -> &UploadManager
fn upload_manager(&self) -> &UploadManager
获取初始化使用的上传管理器
Sourcefn initialize_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Result<Self::InitializedParts, Error>where
D: DataSource<Self::HashAlgorithm> + 'static,
fn initialize_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Result<Self::InitializedParts, Error>where
D: DataSource<Self::HashAlgorithm> + 'static,
Sourcefn upload_part(
&self,
initialized: &Self::InitializedParts,
data_partitioner_provider: &dyn DataPartitionProvider,
) -> Result<Option<Self::UploadedPart>, Error>
fn upload_part( &self, initialized: &Self::InitializedParts, data_partitioner_provider: &dyn DataPartitionProvider, ) -> Result<Option<Self::UploadedPart>, Error>
Sourcefn complete_parts(
&self,
initialized: &Self::InitializedParts,
parts: &[Self::UploadedPart],
) -> Result<Value, Error>
fn complete_parts( &self, initialized: &Self::InitializedParts, parts: &[Self::UploadedPart], ) -> Result<Value, Error>
Sourcefn reinitialize_parts(
&self,
initialized: &mut Self::InitializedParts,
options: ReinitializeOptions,
) -> Result<(), Error>
fn reinitialize_parts( &self, initialized: &mut Self::InitializedParts, options: ReinitializeOptions, ) -> Result<(), Error>
重新初始化分片信息
该步骤负责将先前已经初始化过的分片信息全部重置,清空断点续传记录器中的记录,之后从头上传整个文件
该方法的异步版本为 Self::async_reinitialize_parts
。
Sourcefn try_to_resume_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Option<Self::InitializedParts>where
D: DataSource<Self::HashAlgorithm> + 'static,
fn try_to_resume_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Option<Self::InitializedParts>where
D: DataSource<Self::HashAlgorithm> + 'static,
尝试恢复记录
如果提供了有效的断点续传记录器,该方法可以尝试在找到记录,如果找不到记录,或记录无法读取,则返回 None
。
该方法的异步版本为 Self::try_to_async_resume_parts
。
Sourcefn async_initialize_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Pin<Box<dyn Future<Output = Result<Self::AsyncInitializedParts, Error>> + Send + '_>>where
D: AsyncDataSource<Self::HashAlgorithm> + 'static,
fn async_initialize_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Pin<Box<dyn Future<Output = Result<Self::AsyncInitializedParts, Error>> + Send + '_>>where
D: AsyncDataSource<Self::HashAlgorithm> + 'static,
异步初始化分片信息
该步骤只负责初始化分片,但不实际上传数据,如果提供了有效的断点续传记录器,则可以尝试在这一步找到记录。
Sourcefn async_upload_part<'r>(
&'r self,
initialized: &'r Self::AsyncInitializedParts,
data_partitioner_provider: &'r dyn DataPartitionProvider,
) -> Pin<Box<dyn Future<Output = Result<Option<Self::AsyncUploadedPart>, Error>> + Send + 'r>>
fn async_upload_part<'r>( &'r self, initialized: &'r Self::AsyncInitializedParts, data_partitioner_provider: &'r dyn DataPartitionProvider, ) -> Pin<Box<dyn Future<Output = Result<Option<Self::AsyncUploadedPart>, Error>> + Send + 'r>>
异步上传分片
实际上传的分片大小由提供的分片大小提供者获取。
如果返回 [Ok(None)
] 则表示已经没有更多分片可以上传。
Sourcefn async_complete_parts<'r>(
&'r self,
initialized: &'r Self::AsyncInitializedParts,
parts: &'r [Self::AsyncUploadedPart],
) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + 'r>>
fn async_complete_parts<'r>( &'r self, initialized: &'r Self::AsyncInitializedParts, parts: &'r [Self::AsyncUploadedPart], ) -> Pin<Box<dyn Future<Output = Result<Value, Error>> + Send + 'r>>
异步完成分片上传
在这步成功返回后,对象即可被读取。
Sourcefn async_reinitialize_parts<'r>(
&'r self,
initialized: &'r mut Self::AsyncInitializedParts,
options: ReinitializeOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'r>>
fn async_reinitialize_parts<'r>( &'r self, initialized: &'r mut Self::AsyncInitializedParts, options: ReinitializeOptions, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'r>>
异步重新初始化分片信息
该步骤负责将先前已经初始化过的分片信息全部重置,清空断点续传记录器中的记录,之后从头上传整个文件
Sourcefn try_to_async_resume_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Pin<Box<dyn Future<Output = Option<Self::AsyncInitializedParts>> + Send + '_>>where
D: AsyncDataSource<Self::HashAlgorithm> + 'static,
fn try_to_async_resume_parts<D>(
&self,
source: D,
params: ObjectParams,
) -> Pin<Box<dyn Future<Output = Option<Self::AsyncInitializedParts>> + Send + '_>>where
D: AsyncDataSource<Self::HashAlgorithm> + 'static,
异步尝试恢复记录
如果提供了有效的断点续传记录器,该方法可以尝试在找到记录,如果找不到记录,或记录无法读取,则返回 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.