use async_trait::async_trait;
use derive_new::new;
use serde::Serialize;

use crate::{
    data::{Id, Version},
    interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome},
    inventory::Inventory,
    score::Score,
    topology::Topology,
};

#[derive(Debug, new, Clone, Serialize)]
pub struct IpxeScore {
    //files_to_serve: Url,
}

impl<T: Topology> Score<T> for IpxeScore {
    fn create_interpret(&self) -> Box<dyn Interpret<T>> {
        Box::new(IpxeInterpret::new(self.clone()))
    }

    fn name(&self) -> String {
        "IpxeScore".to_string()
    }
}

#[derive(Debug, new, Clone)]
pub struct IpxeInterpret {
    _score: IpxeScore,
}

#[async_trait]
impl<T: Topology> Interpret<T> for IpxeInterpret {
    async fn execute(
        &self,
        _inventory: &Inventory,
        _topology: &T,
    ) -> Result<Outcome, InterpretError> {
        /*
        let http_server = &topology.http_server;
        http_server.ensure_initialized().await?;
        Ok(Outcome::success(format!(
            "Http Server running and serving files from {}",
            self.score.files_to_serve
        )))
        */
        todo!();
    }

    fn get_name(&self) -> InterpretName {
        InterpretName::Ipxe
    }

    fn get_version(&self) -> Version {
        todo!()
    }

    fn get_status(&self) -> InterpretStatus {
        todo!()
    }

    fn get_children(&self) -> Vec<Id> {
        todo!()
    }
}
