Expand description
Blocking API for cloud provider detection.
This module provides a blocking API for detecting the host’s cloud provider. It is built on top of the asynchronous API and executes the blocking provider identification within threads.
This module is intended for use in synchronous applications or in situations where the asynchronous API is not suitable. While not guaranteed, the performance of this module should be comparable to the asynchronous API.
§Optional
This requires the blocking
feature to be enabled.
§Usage
Add the following to your Cargo.toml
:
# ...
cloud_detect = { version = "2", features = ["blocking"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] } # Optional; for logging
§Examples
Detect the cloud provider and print the result (with default timeout).
use cloud_detect::blocking::detect;
tracing_subscriber::fmt::init(); // Optional; for logging
let provider = detect(None).unwrap();
println!("Detected provider: {:?}", provider);
Detect the cloud provider and print the result (with custom timeout).
use cloud_detect::blocking::detect;
tracing_subscriber::fmt::init(); // Optional; for logging
let provider = detect(Some(10)).unwrap();
println!("Detected provider: {:?}", provider);
Functions§
- detect
- Detects the host’s cloud provider.
- supported_
providers - Returns a list of currently supported providers.