Simple Rust wrapper for the Minehut API. View the documentation by clicking here.
This wrapper does nothing more than allow you to retrieve information from the Minehut API in an organised manner using structs. This is my first Rust project, as well as my first API wrapper.
When handler::all()
is called with the handler products
or servers::icons
, that information is cached. If you're writing an application that needs the information more than once, the cache will eliminate the need to de serialise all of the data multiple times, resulting in a much shorter wait time. This does not apply to the server
handler because the data there is constantly changing.
This is an example programme that you can make with this package:
```rust use minehut::servers; // use servers handler
async fn main() { let mut server = String::new();
loop {
println!("Server name: ");
std::io::stdin()
.read_line(&mut server)
.expect("Could not read line");
// try to get server by name
let server = match servers::server_from_name(&server).await {
// server does not exist
Err(_) => {
println!("Could not find server, try again.");
continue;
},
// found the server
Ok(s) => s
};
println!("Server found: {server:?}");
}
} ```
Apart from this, there is currently no proper documentation. I intend to add a /examples
folder in the near future.
Add this to your Cargo.toml
file:
toml
[dependencies]
minehut = "1.0.0"
Keep in mind you'll need tokio to use the package properly.