[][src]Function online::online

pub async fn online(timeout: Option<u64>) -> Result<bool, Error>

Check if the internet connection is up. When the check succeeds, the returned future is resolved to true.

  • timeout - Number of seconds to wait for a response (default: OS dependent)
use online::*;

#[async_std::main]
async fn main() {
    assert_eq!(online(None).await.unwrap(), true);

    // with timeout
    assert_eq!(online(Some(6)).await.unwrap(), true);
}