pub async fn detect(timeout: Option<u64>) -> ProviderId
Expand description
Detects the host’s cloud provider.
Returns ProviderId::Unknown if the detection failed or timed out. If the detection was successful, it returns a value from ProviderId.
§Arguments
timeout
- Maximum time (seconds) allowed for detection. Defaults to DEFAULT_DETECTION_TIMEOUT ifNone
.
§Examples
Detect the cloud provider and print the result (with default timeout).
use cloud_detect::detect;
#[tokio::main]
async fn main() {
let provider = detect(None).await;
println!("Detected provider: {}", provider);
}
Detect the cloud provider and print the result (with custom timeout).
use cloud_detect::detect;
#[tokio::main]
async fn main() {
let provider = detect(Some(10)).await;
println!("Detected provider: {}", provider);
}