Function detect

Source
pub fn detect(timeout: Option<u64>) -> Result<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::blocking::detect;

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;

let provider = detect(Some(10)).unwrap();
println!("Detected provider: {:?}", provider);