use anyhow::Result;
use async_trait::async_trait;
use std::net::IpAddr;
use crate::config::ServicePort;
use crate::ssh::SshKeypair;
use crate::wg::WireguardManager;
pub mod cloudinit;
pub mod digitalocean;
pub struct ServerSpec {
pub name: String,
pub services: Vec<ServicePort>,
pub wg_mgr: WireguardManager,
pub ssh_client_keypair: SshKeypair,
pub ssh_server_keypair: SshKeypair,
}
#[async_trait]
pub trait Provider: Send + Sync {
async fn create(&self, spec: &ServerSpec) -> Result<Box<dyn InnisfreeServer>>;
}
#[async_trait]
pub trait InnisfreeServer: Send + Sync {
fn server_id(&self) -> String;
fn ipv4_address(&self) -> Result<IpAddr>;
async fn assign_floating_ip(&self, floating_ip: IpAddr) -> Result<()>;
async fn destroy(&self) -> Result<()>;
}