earthmc 2.0.6

Async client for interacting with the EarthMC API
Documentation
use crate::model::{
    named_uuid::NamedUuid,
    query::{SimpleQuery, UuidQuery},
};

pub mod events;
pub mod location;
pub mod mystery_master;
pub mod nations;
pub mod nearby;
pub mod online;
pub mod players;
pub mod quarters;
pub mod server;
pub mod shop;
pub mod towns;

pub trait Endpoint {
    const PATH: &str;
}

pub trait GetEndpoint: Endpoint {
    type Response;
}

pub trait QueryEndpoint: Endpoint {
    type Query;
    type Response;
}

pub struct ServerEndpoint;

impl Endpoint for ServerEndpoint {
    const PATH: &str = "";
}

impl GetEndpoint for ServerEndpoint {
    type Response = server::Server;
}

pub struct TownsEndpoint;

impl Endpoint for TownsEndpoint {
    const PATH: &str = "towns";
}

impl GetEndpoint for TownsEndpoint {
    type Response = Vec<NamedUuid>;
}

impl QueryEndpoint for TownsEndpoint {
    type Query = SimpleQuery;
    type Response = Vec<towns::Town>;
}

pub struct NationsEndpoint;

impl Endpoint for NationsEndpoint {
    const PATH: &str = "nations";
}

impl GetEndpoint for NationsEndpoint {
    type Response = Vec<NamedUuid>;
}

impl QueryEndpoint for NationsEndpoint {
    type Query = SimpleQuery;
    type Response = Vec<nations::Nation>;
}

pub struct NearbyEndpoint;

impl Endpoint for NearbyEndpoint {
    const PATH: &str = "nearby";
}

impl QueryEndpoint for NearbyEndpoint {
    type Query = nearby::NearbyQuery;
    type Response = Vec<Vec<NamedUuid>>;
}

pub struct PlayersEndpoint;

impl Endpoint for PlayersEndpoint {
    const PATH: &str = "players";
}

impl GetEndpoint for PlayersEndpoint {
    type Response = Vec<NamedUuid>;
}

impl QueryEndpoint for PlayersEndpoint {
    type Query = SimpleQuery;

    type Response = Vec<players::Player>;
}

pub struct QuartersEndpoint;

impl Endpoint for QuartersEndpoint {
    const PATH: &str = "quarters";
}

impl GetEndpoint for QuartersEndpoint {
    type Response = Vec<NamedUuid>;
}

impl QueryEndpoint for QuartersEndpoint {
    type Query = UuidQuery;

    type Response = Vec<quarters::Quarter>;
}

pub struct LocationEndpoint;

impl Endpoint for LocationEndpoint {
    const PATH: &str = "location";
}

impl QueryEndpoint for LocationEndpoint {
    type Query = location::LocationQuery;

    type Response = Vec<location::LocationInfo>;
}

pub struct MysteryMasterEndpoint;

impl Endpoint for MysteryMasterEndpoint {
    const PATH: &str = "mm";
}

impl GetEndpoint for MysteryMasterEndpoint {
    type Response = Vec<mystery_master::MysteryMasterEntry>;
}

pub struct OnlineEndpoint;

impl Endpoint for OnlineEndpoint {
    const PATH: &str = "online";
}

impl GetEndpoint for OnlineEndpoint {
    type Response = online::OnlinePlayers;
}

pub struct ShopEndpoint;

impl Endpoint for ShopEndpoint {
    const PATH: &str = "shop";
}

pub struct EventsEndpoint;

impl Endpoint for EventsEndpoint {
    const PATH: &str = "events";
}