mcquery-rs/README.md

57 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

2021-01-08 19:42:24 +01:00
# `mcquery`
A tool for querying Minecraft servers
## What does this crate provide?
- An asynchronous, [`tokio`](https://tokio.rs/)-based library
- Two examples (basic and full queries)
## Usage
To perform a query, call `Query::get_basic` or `Query::get_full`. The
returned response will either be a `BasicQueryResponse` or a `FullQueryResponse`
respectively.
## Examples
```rust
use mcquery::Query;
use std::time::Duration;
#[tokio::main]
async fn main() -> std::io::Result<()> {
let mut basic_query_buffer = [0; 128];
let basic_query = Query::get_basic(
"example.com:25565",
Duration::from_secs(5),
&mut basic_buffer
).await?;
println!("{:#?}", basic_query);
let mut full_query_buffer = [0; 1024];
let full_query = Query::get_full(
"example.com:25565",
Duration::from_secs(5),
&mut buffer
).await?;
println!("{:#?}", full_query);
Ok(())
}
```
## Participation
Feel free to help resolve issues, create new ones, or open a pull request.
## What's next?
- Synchronous queries for those who want them
- A `Packet` trait (currently async trait functions are not supported by Rust)
or `Request`/`Response` structs
## Development resources
Thank you to the [Tokio project](https://tokio.rs/) and the [Minecraft Developer
Wiki](https://wiki.vg/)
for providing a great asynchronous runtime and useful documentation! Without them,
this crate wouldn't be possible.
## License
This project is either licensed under the MIT or the Apache 2.0 license.