1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use auto_impl::auto_impl;
use dyn_clonable::clonable;
use std::{
fmt::Debug,
io::{Read, Result as IoResult},
};
#[cfg(feature = "async")]
use futures::{future::BoxFuture, AsyncRead};
#[derive(Debug, Copy, Clone)]
#[non_exhaustive]
pub enum ResumablePolicy {
MultiPartsUploading,
SinglePartUploading,
}
#[clonable]
#[auto_impl(&, &mut, Box, Rc, Arc)]
pub trait ResumablePolicyProvider: Clone + Debug + Sync + Send {
fn get_policy_from_size(&self, source_size: u64, opts: GetPolicyOptions) -> ResumablePolicy;
fn get_policy_from_reader<'a>(
&self,
reader: Box<dyn DynRead + 'a>,
opts: GetPolicyOptions,
) -> IoResult<(ResumablePolicy, Box<dyn DynRead + 'a>)>;
#[cfg(feature = "async")]
#[cfg_attr(feature = "docs", doc(cfg(feature = "async")))]
fn get_policy_from_async_reader<'a>(
&self,
reader: Box<dyn DynAsyncRead + 'a>,
opts: GetPolicyOptions,
) -> BoxFuture<'a, IoResult<(ResumablePolicy, Box<dyn DynAsyncRead + 'a>)>>;
}
#[derive(Debug, Copy, Clone, Default)]
pub struct GetPolicyOptions {}
pub trait DynRead: Read + Debug + Send + Sync {}
impl<T: Read + Debug + Send + Sync> DynRead for T {}
#[cfg(feature = "async")]
#[cfg_attr(feature = "docs", doc(cfg(feature = "async")))]
pub trait DynAsyncRead: AsyncRead + Debug + Unpin + Send + Sync {}
#[cfg(feature = "async")]
impl<T: AsyncRead + Debug + Unpin + Send + Sync> DynAsyncRead for T {}
mod always_single_part;
pub use always_single_part::AlwaysSinglePart;
mod always_multi_parts;
pub use always_multi_parts::AlwaysMultiParts;
mod fixed;
pub use fixed::FixedThresholdResumablePolicy;
mod multiple_partitions;
pub use multiple_partitions::MultiplePartitionsResumablePolicyProvider;