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
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::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);