use cidr::Ipv4Cidr;
use derive_new::new;

use super::{IpAddress, LogicalHost};

pub trait Router: Send + Sync {
    fn get_gateway(&self) -> IpAddress;
    fn get_cidr(&self) -> Ipv4Cidr;
    fn get_host(&self) -> LogicalHost;
}

impl std::fmt::Debug for dyn Router {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_fmt(format_args!(
            "Router Gateway : {}, CIDR : {}",
            self.get_gateway(),
            self.get_cidr()
        ))
    }
}

#[derive(new)]
pub struct UnmanagedRouter {
    gateway: IpAddress,
    cidr: Ipv4Cidr,
}

impl Router for UnmanagedRouter {
    fn get_gateway(&self) -> IpAddress {
        self.gateway.clone()
    }

    fn get_cidr(&self) -> Ipv4Cidr {
        self.cidr.clone()
    }

    fn get_host(&self) -> LogicalHost {
        todo!()
    }
}
