Function mcping::get_status[][src]

pub fn get_status(
    address: &str,
    timeout: impl Into<Option<Duration>>
) -> Result<(u64, Response), Error>

Retrieve the status of a given Minecraft server by its address.

A timeout can be optionally provided for use when attempting to connect to the server.

Returns (latency_ms, response).

Examples

Ping a server with no timeout:

let (latency, response) = mcping::get_status("mc.hypixel.net", None)?;

Ping a server with a timeout of 10 seconds:

use std::time::Duration;

let (latency, response) = mcping::get_status("mc.hypixel.net", Duration::from_secs(10))?;