s3/
lib.rs

1//! Simple access to Amazon Web Service's (AWS) Simple Storage Service (S3)
2#![forbid(unsafe_code)]
3
4#[macro_use]
5extern crate serde_derive;
6
7use std::sync::atomic::AtomicU8;
8
9pub use awscreds as creds;
10pub use awsregion as region;
11
12pub use bucket::Bucket;
13pub use bucket::Tag;
14pub use bucket_ops::BucketConfiguration;
15pub use post_policy::{PostPolicy, PostPolicyChecksum, PostPolicyField, PostPolicyValue};
16pub use put_object_request::PutObjectRequest;
17#[cfg(any(feature = "with-tokio", feature = "with-async-std"))]
18pub use put_object_request::PutObjectStreamRequest;
19pub use region::Region;
20
21pub mod bucket;
22pub mod bucket_ops;
23pub mod command;
24pub mod deserializer;
25pub mod post_policy;
26pub mod put_object_request;
27pub mod serde_types;
28pub mod signing;
29
30pub mod error;
31pub mod request;
32pub mod utils;
33
34const LONG_DATETIME: &[time::format_description::FormatItem<'static>] =
35    time::macros::format_description!("[year][month][day]T[hour][minute][second]Z");
36const EMPTY_PAYLOAD_SHA: &str = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
37
38static RETRIES: AtomicU8 = AtomicU8::new(1);
39
40/// Sets the number of retries for operations that may fail and need to be retried.
41///
42/// This function stores the specified number of retries in an atomic variable,
43/// which can be safely shared across threads. This is used by the retry! macro to automatically retry all requests.
44///
45/// # Arguments
46///
47/// * `retries` - The number of retries to set.
48///
49/// # Example
50///
51/// ```rust
52/// s3::set_retries(3);
53/// ```
54pub fn set_retries(retries: u8) {
55    RETRIES.store(retries, std::sync::atomic::Ordering::SeqCst);
56}
57
58/// Retrieves the current number of retries set for operations.
59///
60/// This function loads the value of the atomic variable storing the number of retries,
61/// which can be safely accessed across threads.
62///
63/// # Returns
64///
65/// The number of retries currently set, as a `u64`.
66///
67/// # Example
68///
69/// ```rust
70/// let retries = s3::get_retries();
71/// ```
72pub fn get_retries() -> u8 {
73    RETRIES.load(std::sync::atomic::Ordering::Relaxed)
74}