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
47pub use google_cloud_gax::Result;
48pub use google_cloud_gax::error::Error;
49// Define some shortcuts for imported crates.
50pub(crate) use google_cloud_gax::client_builder::ClientBuilder;
51pub(crate) use google_cloud_gax::client_builder::Result as ClientBuilderResult;
52pub(crate) use google_cloud_gax::client_builder::internal::ClientFactory;
53pub(crate) use google_cloud_gax::client_builder::internal::new_builder as new_client_builder;
54pub(crate) use google_cloud_gax::options::RequestOptions;
55pub(crate) use google_cloud_gax::options::internal::RequestBuilder;
56pub(crate) use google_cloud_gax::response::Response;
57
58pub mod backoff_policy;
59pub mod object_descriptor;
60pub mod read_object;
61pub mod read_resume_policy;
62pub mod retry_policy;
63pub mod signed_url;
64pub use crate::storage::request_options;
65pub use crate::storage::streaming_source;
66
67/// Re-export types from the `http` crate used in this module.
68pub mod http {
69 // Note: The empty doc lines below create a paragraph break in Markdown.
70 // This prevents rustdoc from appending the inlined external documentation
71 // to our short descriptions in the module summary list.
72
73 /// HTTP method used by the [SignedUrlBuilder][crate::builder::storage::SignedUrlBuilder].
74 ///
75 ///
76 pub use http::Method;
77
78 /// Metadata attributes used by the [Client::open_object][crate::client::Storage::open_object].
79 ///
80 ///
81 pub use http::HeaderMap;
82}
83
84mod control;
85mod storage;
86
87pub mod client {
88 //! Clients to interact with Google Cloud Storage.
89 pub use crate::control::client::StorageControl;
90 pub use crate::storage::client::Storage;
91}
92pub mod builder {
93 //! Request builders.
94 pub mod storage {
95 //! Request builders for [Storage][crate::client::Storage].
96 pub use crate::storage::client::ClientBuilder;
97 pub use crate::storage::open_object::OpenObject;
98 pub use crate::storage::read_object::ReadObject;
99 pub use crate::storage::signed_url::SignedUrlBuilder;
100 pub use crate::storage::write_object::WriteObject;
101 }
102 pub mod storage_control {
103 //! Request builders for [StorageControl][crate::client::StorageControl].
104 pub use crate::control::builder::*;
105 pub use crate::control::client::ClientBuilder;
106 }
107}
108pub mod error;
109pub use crate::control::model;
110pub mod builder_ext;
111pub mod model_ext;
112pub mod stub {
113 //! Traits to mock the clients in this library.
114 //!
115 //! Application developers may need to mock the clients in this library to test
116 //! how their application works with different (and sometimes hard to trigger)
117 //! client and service behavior. Such test can define mocks implementing the
118 //! trait(s) defined in this module, initialize the client with an instance of
119 //! this mock in their tests, and verify their application responds as expected.
120 pub use crate::control::stub::*;
121 pub use crate::storage::stub::*;
122 pub use crate::storage::transport::Storage as DefaultStorage;
123}
124
125#[allow(dead_code)]
126pub(crate) mod generated;
127
128#[allow(dead_code)]
129pub(crate) mod google {
130 pub mod iam {
131 pub mod v1 {
132 include!("generated/protos/storage/google.iam.v1.rs");
133 include!("generated/convert/iam/convert.rs");
134 }
135 }
136 pub mod longrunning {
137 include!("generated/protos/control/google.longrunning.rs");
138 include!("generated/convert/longrunning/convert.rs");
139 }
140 pub(crate) mod control_type {
141 // google.storage.v2.control uses a different set of types from google.type vs.
142 // google.storage.v2. We need to define them in a separate module to avoid conflicts and
143 // manually re-export some key symbols.
144 include!("generated/protos/control/google.r#type.rs");
145 }
146 pub mod r#type {
147 // Re-export the google.type.Interval type generated for storage control. Unfortunately
148 // none of the tonic-generated files has all the types from google.type that we need.
149 pub use super::control_type::Interval;
150 include!("generated/protos/storage/google.r#type.rs");
151 include!("generated/convert/type/convert.rs");
152 }
153 pub mod rpc {
154 include!("generated/protos/storage/google.rpc.rs");
155 }
156 pub mod storage {
157 #[allow(deprecated)]
158 #[allow(clippy::large_enum_variant)]
159 pub mod v2 {
160 include!("generated/protos/storage/google.storage.v2.rs");
161 include!("generated/convert/storage/convert.rs");
162 }
163 pub mod control {
164 pub mod v2 {
165 include!("generated/protos/control/google.storage.control.v2.rs");
166 include!("generated/convert/control/convert.rs");
167 }
168 }
169 }
170 #[allow(unused_imports)]
171 pub mod protobuf {
172 pub use gaxi::prost::Empty;
173 }
174}