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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
pub mod client; mod test; use serde::Deserialize; #[derive(Debug, Deserialize)] struct DbxRequestLimitsErrorSummary { error_summary: String, error: DbxRequestErrorReason, } #[derive(Debug, Deserialize)] struct DbxRequestErrorSummary { error_summary: String, error: DbxRequestErrorTag, } #[derive(Debug, Deserialize)] struct DbxRequestErrorReason { reason: DbxRequestErrorTag, retry_after: u32, } #[derive(Debug, Deserialize)] struct DbxRequestErrorTag { #[serde(alias = ".tag")] tag: String, } #[derive(Debug, Deserialize)] struct UserCheckResult { result: String, } pub type DropboxResult<T> = std::result::Result<T, DropboxError>; #[derive(Debug)] pub enum DropboxError { #[cfg(feature = "non-blocking")] NonBlockingRequestError(reqwest::Error), #[cfg(feature = "blocking")] BlockingRequestError(ureq::Error), DbxUserCheckError(String), DbxPathError(String), DbxExistedError(String), DbxInvalidTokenError(String), DbxFromLookUpError(String), DbxRequestLimitsError(String), DbxAccessError(String), DbxConflictError(String), DbxServerError(String), OtherError(String), #[cfg(feature = "blocking")] BodyParseError(std::io::Error), } #[cfg(feature = "blocking")] impl From<std::io::Error> for DropboxError { fn from(e: std::io::Error) -> Self { Self::BodyParseError(e) } } #[cfg(feature = "non-blocking")] impl From<reqwest::Error> for DropboxError { fn from(e: reqwest::Error) -> Self { Self::NonBlockingRequestError(e) } } #[cfg(feature = "blocking")] impl From<ureq::Error> for DropboxError { fn from(e: ureq::Error) -> Self { Self::BlockingRequestError(e) } } pub struct MoveOption { allow_shared_folder: bool, auto_rename: bool, allow_ownership_transfer: bool, } impl MoveOption { pub fn new() -> Self { Self { allow_shared_folder: false, auto_rename: false, allow_ownership_transfer: false, } } pub fn allow_shared_folder(mut self) -> Self { self.allow_shared_folder = true; self } pub fn allow_auto_rename(mut self) -> Self { self.auto_rename = true; self } pub fn allow_ownership_transfer(mut self) -> Self { self.allow_ownership_transfer = true; self } } pub enum UploadMode { Add, Overwrite, }