earthmc 2.0.6

Async client for interacting with the EarthMC API
Documentation
use std::sync::Arc;

use earthmc::{
    client::ClientBuilder, endpoints::location::LocationQueryBuilder,
    model::location::PositionXZ, retry_strategy::NeverRetry,
};
use parking_lot::Mutex;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ClientBuilder::default()
        .retry_strategy(Arc::new(Mutex::new(NeverRetry)))
        .build();

    let query = LocationQueryBuilder::default()
        .insert(PositionXZ::new(0.0, -12250.0))
        .insert(PositionXZ::new(-26475.0, -7550.0))
        .insert(PositionXZ::new(i32::MAX as f32, i32::MAX as f32))
        .build()?;

    let results = client.locations(query).await?;

    for result in results {
        let (x, z) = (result.location.x, result.location.z);
        if result.is_wilderness {
            println!("[{x},{z}] is in the wilderness");
        } else {
            println!("[{x},{z}] is in {}", result.town.name.unwrap());
        }
    }

    Ok(())
}