cloud_storage_lite/
lib.rs

1#![deny(rust_2018_idioms, unreachable_pub, missing_docs)]
2#![forbid(unsafe_code)]
3
4//! # cloud-storage-lite
5//!
6//! A simple, flexible Google Cloud Storage client (GCS).
7//!
8//! This library isn't as featureful as, say the [cloud-storage](https://crates.io/crates/cloud-storage) crate, but it's also more usable if you:
9//! * are using a secret keeper like [Vault](https://www.vaultproject.io)
10//! * generally work with a single bucket (using a bucket-scoped client)
11//! * would like to use multiple clients or tokio runtimes in one program
12//! * want canonicalized errors (404 gets one and only one error variant)
13//!
14//! ## Example
15//!
16//! ```no_run
17//! use cloud_storage_lite::{
18//!  self as gcs,
19//!  client::BucketClient,
20//!  token_provider::{self, oauth::{self, OAuthTokenProvider, ServiceAccount}},
21//! };
22//! use futures::TryStreamExt;
23//!
24//! #[tokio::main]
25//! async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
26//!   let token_provider = token_provider::RenewingTokenProvider::new(
27//!     OAuthTokenProvider::new(
28//!       ServiceAccount::read_from_canonical_env()?,
29//!       oauth::SCOPE_STORAGE_FULL_CONTROL,
30//!     )?
31//!   );
32//!   let client = gcs::Client::new(token_provider).into_bucket_client("my-bucket".into());
33//!
34//!   client
35//!     .create_object(
36//!       "key",
37//!       futures::stream::once(
38//!         futures::future::ok::<_, std::convert::Infallible>(b"value".to_vec())
39//!       )
40//!     )
41//!     .await?;
42//!
43//!   let object = client.get_object("key").await?;
44//!
45//!   let value_bytes = client
46//!     .download_object(&object.name)
47//!     .await?
48//!     .map_ok(|chunk| chunk.to_vec())
49//!     .try_concat()
50//!     .await?;
51//!
52//!   println!("the value is: {}", String::from_utf8(value_bytes)?);
53//!   Ok(())
54//! }
55//! ```
56
57pub mod api;
58pub mod client;
59pub mod errors;
60pub mod token_provider;
61
62pub use client::Client;
63pub use errors::Error;
64pub use token_provider::TokenProvider;