pub mod client;
pub mod craftycontroller;
pub mod local;
pub mod mock;
pub mod models;
pub mod pterodactyl;
use std::fmt::Debug;
use crate::{ServerState, error::ServerManagerError};
use async_trait::async_trait;
#[async_trait]
pub trait ApiProvider: Send + Sync + Debug {
async fn get_server_status(
&self,
server_id: &str,
) -> Result<ApiServerStatus, ServerManagerError>;
async fn start_server(&self, server_id: &str) -> Result<(), ServerManagerError>;
async fn stop_server(&self, server_id: &str) -> Result<(), ServerManagerError>;
async fn restart_server(&self, server_id: &str) -> Result<(), ServerManagerError> {
self.stop_server(server_id).await?;
self.start_server(server_id).await
}
}
#[derive(Debug, Clone)]
pub struct ApiServerStatus {
pub id: String,
pub name: String,
pub status: ServerState,
pub is_running: bool,
pub is_crashed: bool,
pub error: Option<String>,
}
pub use client::ApiClient;
pub use craftycontroller::CraftyClient;
pub use local::LocalProvider;
pub use mock::MockApiProvider;
pub use models::*;
pub use pterodactyl::PterodactylClient;