18 releases (5 stable)
Uses new Rust 2024
| 1.3.0 | Jan 28, 2026 |
|---|---|
| 1.2.0 | Dec 9, 2025 |
| 1.1.1 | Nov 14, 2025 |
| 0.4.0 | Sep 5, 2025 |
| 0.1.0 | Feb 18, 2025 |
#2836 in Network programming
429,559 downloads per month
Used in 137 crates
(120 directly)
1.5MB
29K
SLoC
Google Cloud Client Libraries for Rust - Long-running Operation Support
The Client Libraries for Rust are under active development. We are creating placeholder crates so we can reference them in our code and tooling.
lib.rs:
Types and functions to make LROs easier to use and to require less boilerplate.
Occasionally, a Google Cloud service may need to expose a method that takes a significant amount of time to complete. In these situations, it is often a poor user experience to simply block while the task runs. Such services return a long-running operation, a type of promise that can be polled until it completes successfully.
Polling these operations can be tedious. The application needs to periodically make RPCs, extract the result from the response, and may need to implement a stream to return metadata representing any progress in the RPC.
The Google Cloud client libraries for Rust return implementations of this trait to simplify working with these long-running operations.
Example: automatically poll until completion
async fn start_lro() -> impl Poller<Response, Metadata> {
// ... details omitted ...
# async fn start() -> Result<Operation<Response, Metadata>> { panic!(); }
# async fn query(_: String) -> Result<Operation<Response, Metadata>> { panic!(); }
# google_cloud_lro::internal::new_poller(
# std::sync::Arc::new(gax::polling_error_policy::AlwaysContinue),
# std::sync::Arc::new(gax::exponential_backoff::ExponentialBackoff::default()),
# start, query
# )
}
let response = start_lro()
.await
.until_done()
.await?;
println!("response = {response:?}");
Example: poll with metadata
async fn start_lro() -> impl Poller<Response, Metadata> {
// ... details omitted ...
# async fn start() -> Result<Operation<Response, Metadata>> { panic!(); }
# async fn query(_: String) -> Result<Operation<Response, Metadata>> { panic!(); }
# google_cloud_lro::internal::new_poller(
# std::sync::Arc::new(gax::polling_error_policy::AlwaysContinue),
# std::sync::Arc::new(gax::exponential_backoff::ExponentialBackoff::default()),
# start, query
# )
}
let mut poller = start_lro().await;
while let Some(p) = poller.poll().await {
match p {
PollingResult::Completed(r) => { println!("LRO completed, response={r:?}"); }
PollingResult::InProgress(m) => { println!("LRO in progress, metadata={m:?}"); }
PollingResult::PollingError(e) => { println!("Transient error polling the LRO: {e}"); }
}
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
}
Dependencies
~17–35MB
~391K SLoC