s3handler/
lib.rs

1//! Initilize S3 handler to manipulate objects and buckets
2//! use s3handler = { features = ["blocking"] }
3//! ```
4//! let config = s3handler::blocking::CredentialConfig{
5//!     host: "s3.us-east-1.amazonaws.com".to_string(),
6//!     access_key: "akey".to_string(),
7//!     secret_key: "skey".to_string(),
8//!     user: None,
9//!     region: None, // default is us-east-1
10//!     s3_type: None, // default will try to config as AWS S3 handler
11//!     secure: None, // dafault is false, because the integrity protect by HMAC
12//! };
13//! let mut handler = s3handler::blocking::Handler::from(&config);
14//! let _ = handler.la();
15//! ```
16//!
17//! Download a file with async api
18//! use s3handler = { features = ["tokio-async"] }
19//! ```
20//! // Public resource
21//! let s3_pool = s3handler::none_blocking::primitives::S3Pool::new("somewhere.in.the.world".to_string());
22//! let obj = s3_pool.bucket("bucket_name").object("objcet_name");
23//! async {
24//!     obj.download_file("/path/to/save/a/file").await;
25//! };
26//!
27//! ```
28//!
29//! S3 async handler to manipulate objects and buckets.
30//! This treat all data as pool and create a canal to bridge two pool.
31//! It is easy to management and sync data from folder to S3, S3 to S3, event folder to folder.
32//!
33//! >>>no_run
34//!        +------+
35//!        | Pool | (UpPool)  modify by *from_* prefixed api
36//!        +------+
37//!          |  ^
38//!     Pull |  | Push
39//!          v  |
40//!        +------+
41//!        | Pool | (DownPool) modify by *toward_* prefixed api
42//!        +------+
43//! >>>
44//!
45//! ```
46//! use s3handler::none_blocking::traits::DataPool;
47//!
48//! // Resource with AWS version 2 auth
49//! let s3_pool = s3handler::none_blocking::primitives::S3Pool::new("somewhere.in.the.world".to_string())
50//!         .aws_v2("access-key".to_string(), "secrete-key".to_string());
51//! let bucket = s3_pool.bucket("bucket_name");
52//! // Actually the bucket is a unconnnected canal
53//! assert!(!bucket.is_connect());
54//! let canal = bucket.toward("/path/to/another/folder").unwrap();
55//! // The canal bridges the two folder and ready to transfer data between bucket and folder
56//! assert!(canal.is_connect());
57//! // canal.sync().awit;
58//! ```
59
60#[cfg(feature = "blocking")]
61pub mod blocking;
62#[cfg(feature = "blocking")]
63pub use blocking::*;
64
65// #[cfg(feature = "std-async")]
66// pub mod async_std;
67
68#[cfg(feature = "tokio-async")]
69pub mod tokio_async;
70#[cfg(feature = "tokio-async")]
71pub use tokio_async as none_blocking;
72
73pub mod error;
74pub use utils::{S3Convert, S3Object};
75pub mod utils;