Function detect

Source
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

§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);
}