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
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    /// HTTP method used by the [SignedUrlBuilder][crate::builder::storage::SignedUrlBuilder].
70    pub use http::Method;
71
72    /// Metadata attributes used by the [Client::open_object][crate::client::Storage::open_object].
73    pub use http::HeaderMap;
74}
75
76mod control;
77mod storage;
78
79pub mod client {
80    //! Clients to interact with Google Cloud Storage.
81    pub use crate::control::client::StorageControl;
82    pub use crate::storage::client::Storage;
83}
84pub mod builder {
85    //! Request builders.
86    pub mod storage {
87        //! Request builders for [Storage][crate::client::Storage].
88        pub use crate::storage::client::ClientBuilder;
89        pub use crate::storage::open_object::OpenObject;
90        pub use crate::storage::read_object::ReadObject;
91        pub use crate::storage::signed_url::SignedUrlBuilder;
92        pub use crate::storage::write_object::WriteObject;
93    }
94    pub mod storage_control {
95        //! Request builders for [StorageControl][crate::client::StorageControl].
96        pub use crate::control::builder::*;
97        pub use crate::control::client::ClientBuilder;
98    }
99}
100pub mod error;
101/// The messages and enums that are part of this client library.
102pub use crate::control::model;
103pub mod builder_ext;
104pub mod model_ext;
105pub mod stub {
106    //! Traits to mock the clients in this library.
107    //!
108    //! Application developers may need to mock the clients in this library to test
109    //! how their application works with different (and sometimes hard to trigger)
110    //! client and service behavior. Such test can define mocks implementing the
111    //! trait(s) defined in this module, initialize the client with an instance of
112    //! this mock in their tests, and verify their application responds as expected.
113    pub use crate::control::stub::*;
114    pub use crate::storage::stub::*;
115    pub use crate::storage::transport::Storage as DefaultStorage;
116}
117
118#[allow(dead_code)]
119pub(crate) mod generated;
120
121#[allow(dead_code)]
122pub(crate) mod google {
123    pub mod iam {
124        pub mod v1 {
125            include!("generated/protos/storage/google.iam.v1.rs");
126            include!("generated/convert/iam/convert.rs");
127        }
128    }
129    pub mod longrunning {
130        include!("generated/protos/control/google.longrunning.rs");
131        include!("generated/convert/longrunning/convert.rs");
132    }
133    pub mod r#type {
134        include!("generated/protos/storage/google.r#type.rs");
135        include!("generated/convert/type/convert.rs");
136    }
137    pub mod rpc {
138        include!("generated/protos/storage/google.rpc.rs");
139    }
140    pub mod storage {
141        #[allow(deprecated)]
142        #[allow(clippy::large_enum_variant)]
143        pub mod v2 {
144            include!("generated/protos/storage/google.storage.v2.rs");
145            include!("generated/convert/storage/convert.rs");
146        }
147        pub mod control {
148            pub mod v2 {
149                include!("generated/protos/control/google.storage.control.v2.rs");
150                include!("generated/convert/control/convert.rs");
151            }
152        }
153    }
154    #[allow(unused_imports)]
155    pub mod protobuf {
156        pub use gaxi::prost::Empty;
157    }
158}