Skip to main content

google_cloud_storage/
lib.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Google Cloud Client Libraries for Rust - Storage
16//!
17//! This crate contains traits, types, and functions to interact with [Google
18//! Cloud Storage]. Most applications will use the structs defined in the
19//! [client] module. More specifically:
20//!
21//! * [Storage][client::Storage]
22//! * [StorageControl][client::StorageControl]
23//! * [SignedUrlBuilder][builder::storage::SignedUrlBuilder]
24//!
25//! **NOTE:** This crate used to contain a different implementation, with a
26//! different surface. [@yoshidan](https://github.com/yoshidan) generously
27//! donated the crate name to Google. Their crate continues to live as
28//! [gcloud-storage].
29//!
30//! # Features
31//!
32//! - `default-rustls-provider`: enabled by default. Use the default rustls crypto
33//!   provider ([aws-lc-rs]) for TLS and authentication. Applications with specific
34//!   requirements for cryptography (such as exclusively using the [ring] crate)
35//!   should disable this default and call
36//!   `rustls::crypto::CryptoProvider::install_default()`.
37//! - `unstable-stream`: enable the (unstable) features to convert several types to
38//!   a `future::Stream`.
39//!
40//! [aws-lc-rs]: https://crates.io/crates/aws-lc-rs
41//! [gcloud-storage]: https://crates.io/crates/gcloud-storage
42//! [Google Cloud Storage]: https://cloud.google.com/storage
43//! [ring]: https://crates.io/crates/ring
44
45#![cfg_attr(docsrs, feature(doc_cfg))]
46#![warn(missing_docs)]
47
48pub use google_cloud_gax::Result;
49pub use google_cloud_gax::error::Error;
50// Define some shortcuts for imported crates.
51pub(crate) use google_cloud_gax::client_builder::ClientBuilder;
52pub(crate) use google_cloud_gax::client_builder::Result as ClientBuilderResult;
53pub(crate) use google_cloud_gax::client_builder::internal::ClientFactory;
54pub(crate) use google_cloud_gax::client_builder::internal::new_builder as new_client_builder;
55pub(crate) use google_cloud_gax::options::RequestOptions;
56pub(crate) use google_cloud_gax::options::internal::RequestBuilder;
57pub(crate) use google_cloud_gax::response::Response;
58
59pub mod backoff_policy;
60pub mod object_descriptor;
61pub mod read_object;
62pub mod read_resume_policy;
63pub mod retry_policy;
64pub mod signed_url;
65pub use crate::storage::request_options;
66pub use crate::storage::streaming_source;
67
68/// Re-export types from the `http` crate used in this module.
69pub mod http {
70    // Note: The empty doc lines below create a paragraph break in Markdown.
71    // This prevents rustdoc from appending the inlined external documentation
72    // to our short descriptions in the module summary list.
73
74    /// HTTP method used by the [SignedUrlBuilder][crate::builder::storage::SignedUrlBuilder].
75    ///
76    ///
77    pub use http::Method;
78
79    /// Metadata attributes used by the [Client::open_object][crate::client::Storage::open_object].
80    ///
81    ///
82    pub use http::HeaderMap;
83}
84
85mod control;
86mod storage;
87
88pub mod client {
89    //! Clients to interact with Google Cloud Storage.
90    pub use crate::control::client::StorageControl;
91    pub use crate::storage::client::Storage;
92}
93pub mod builder {
94    //! Request builders.
95    pub mod storage {
96        //! Request builders for [Storage][crate::client::Storage].
97        pub use crate::storage::client::ClientBuilder;
98        pub use crate::storage::open_object::OpenObject;
99        pub use crate::storage::read_object::ReadObject;
100        pub use crate::storage::signed_url::SignedUrlBuilder;
101        pub use crate::storage::write_object::WriteObject;
102    }
103    pub mod storage_control {
104        //! Request builders for [StorageControl][crate::client::StorageControl].
105        pub use crate::control::builder::*;
106        pub use crate::control::client::ClientBuilder;
107    }
108}
109pub mod error;
110pub use crate::control::model;
111pub mod builder_ext;
112pub mod model_ext;
113pub mod stub {
114    //! Traits to mock the clients in this library.
115    //!
116    //! Application developers may need to mock the clients in this library to test
117    //! how their application works with different (and sometimes hard to trigger)
118    //! client and service behavior. Such test can define mocks implementing the
119    //! trait(s) defined in this module, initialize the client with an instance of
120    //! this mock in their tests, and verify their application responds as expected.
121    pub use crate::control::stub::*;
122    pub use crate::storage::stub::*;
123    pub use crate::storage::transport::Storage as DefaultStorage;
124}
125
126#[allow(dead_code)]
127pub(crate) mod generated;
128
129#[allow(dead_code)]
130pub(crate) mod google {
131    pub mod iam {
132        pub mod v1 {
133            include!("generated/protos/storage/google.iam.v1.rs");
134            include!("generated/convert/iam/convert.rs");
135        }
136    }
137    pub mod longrunning {
138        include!("generated/protos/control/google.longrunning.rs");
139        include!("generated/convert/longrunning/convert.rs");
140    }
141    pub mod r#type {
142        include!("generated/protos/storage/google.r#type.rs");
143        include!("generated/convert/type/convert.rs");
144    }
145    pub mod rpc {
146        include!("generated/protos/storage/google.rpc.rs");
147    }
148    pub mod storage {
149        #[allow(deprecated)]
150        #[allow(clippy::large_enum_variant)]
151        pub mod v2 {
152            include!("generated/protos/storage/google.storage.v2.rs");
153            include!("generated/convert/storage/convert.rs");
154        }
155        pub mod control {
156            pub mod v2 {
157                include!("generated/protos/control/google.storage.control.v2.rs");
158                include!("generated/convert/control/convert.rs");
159            }
160        }
161    }
162    #[allow(unused_imports)]
163    pub mod protobuf {
164        pub use gaxi::prost::Empty;
165    }
166}