| Crates.io | craftping |
| lib.rs | craftping |
| version | 0.7.0 |
| created_at | 2019-03-23 10:17:03.715849+00 |
| updated_at | 2025-03-17 17:42:49.669335+00 |
| description | Minecraft Server List Ping Implementation |
| homepage | |
| repository | https://github.com/kiwiyou/craftping |
| max_upload_size | |
| id | 123268 |
| size | 53,816 |
craftping is a Rust library to ping Minecraft Servers.
[dependencies]
craftping = "0.7.0"
You can synchronously ping to the server with craftping::sync::ping:
use std::net::TcpStream;
use craftping::sync::ping;
fn main() {
let hostname = "localhost";
let port = 25565;
let mut stream = TcpStream::connect((hostname, port)).unwrap();
let pong = ping(&mut stream, hostname, port).expect("Cannot ping server");
println!("Ping result: {:?}", pong);
}
sync module requires sync feature, which is enabled by default.
If you want to send pings asynchronously, you can use craftping::tokio::ping or craftping::futures::ping:
craftping::tokio::pinguse tokio::net::TcpStream;
use craftping::tokio::ping;
#[tokio::main]
async fn main() {
let hostname = "localhost";
let port = 25565;
let mut stream = TcpStream::connect((hostname, port)).await.unwrap();
let pong = ping(&mut stream, hostname, port).await.expect("Cannot ping server");
println!("Ping result: {:?}", pong);
}
craftping::futures::pinguse async_std::net::TcpStream;
use craftping::futures::ping;
#[async_std::main]
async fn main() {
let hostname = "localhost";
let port = 25565;
let mut stream = TcpStream::connect((hostname, port)).await.unwrap();
let pong = ping(&mut stream, hostname, port).await.expect("Cannot ping server");
println!("Ping result: {:?}", pong);
}
Note that tokio module requires async-tokio feature and futures async-futures.
Check here for more information about ping result.
Pull requests are welcome. For major issues, please open the issue on this repository first.