gcs_rsync/
lib.rs

1//! Fast and native Google Cloud Storage rsync
2//!
3//! - __fast__: gcs-rsync performance are better than gsutil rsync: see [benchmark](https://github.com/cboudereau/gcs-rsync#benchmark)
4//! - __native__: gcs-rsync can be used without gcloud components
5//! - __gcs auth__: __authorized user__ (dev account) and __service account__
6//! - __features__: source and destination can be either fs (_file system_) or gcs (_Google Cloud Storage_) meaning that any combination is allowed
7//!
8//! __Be careful__ with the __mirror__ feature as it will __delete all extras__ meaning that entry not found in the source is deleted from the destination
9//!
10//! # Quick Start
11//! ```rust
12//! use std::{path::PathBuf, str::FromStr};
13//!
14//! use futures::{StreamExt, TryStreamExt};
15//! use gcs_rsync::{
16//!     storage::credentials::authorizeduser,
17//!     sync::{RSync, RSyncResult, ReaderWriter},
18//! };
19//!
20//! #[tokio::main]
21//! async fn main() -> RSyncResult<()> {
22//!     let token_generator = Box::new(authorizeduser::default().await.unwrap());
23//!
24//!     let home_dir = ".";
25//!     let test_prefix = "bucket_prefix_to_sync";
26//!     let bucket = "bucket_name";
27//!
28//!     let source = ReaderWriter::gcs(token_generator, bucket, test_prefix)
29//!         .await
30//!         .unwrap();
31//!
32//!     let dest_folder = {
33//!         let mut p = PathBuf::from_str(home_dir).unwrap();
34//!         p.push(test_prefix);
35//!         p
36//!     };
37//!     let dest = ReaderWriter::fs(dest_folder.as_path());
38//!
39//!     let rsync = RSync::new(source, dest);
40//!
41//!     rsync
42//!         .sync()
43//!         .await
44//!         .try_buffer_unordered(12)
45//!         .for_each(|x| {
46//!             println!("{:?}", x);
47//!             futures::future::ready(())
48//!         })
49//!         .await;
50//!
51//!     Ok(())
52//! }
53//! ```
54//! # Sync and Mirror examples
55//! - [`gcp::sync::RSync`] examples
56//! - [other examples](https://github.com/cboudereau/gcs-rsync/tree/main/examples)
57mod gcp;
58
59pub use gcp::oauth2;
60pub use gcp::sync;
61pub use gcp::{storage, Client};
62
63const DEFAULT_BUF_SIZE: usize = 64 * 1024;