//! `detection_client` — bi-directional gRPC to `../detections`.
//!
//! Real implementation lands in:
//! - AZ-660 `detection_client_grpc_stream`
//! - AZ-661 `detection_client_schema_and_health`

use shared::error::{AutopilotError, Result};
use shared::health::ComponentHealth;
use shared::models::detection::DetectionBatch;
use shared::models::frame::Frame;

const NAME: &str = "detection_client";

#[derive(Debug, Clone)]
pub struct DetectionClient {
    pub endpoint: String,
}

impl DetectionClient {
    pub fn new(endpoint: String) -> Self {
        Self { endpoint }
    }

    pub fn handle(&self) -> DetectionClientHandle {
        DetectionClientHandle {
            endpoint: self.endpoint.clone(),
        }
    }
}

#[derive(Debug, Clone)]
pub struct DetectionClientHandle {
    #[allow(dead_code)]
    endpoint: String,
}

impl DetectionClientHandle {
    pub async fn request(&self, _frame: Frame) -> Result<DetectionBatch> {
        Err(AutopilotError::NotImplemented(
            "detection_client::request (AZ-660)",
        ))
    }

    pub fn health(&self) -> ComponentHealth {
        ComponentHealth::disabled(NAME)
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_compiles() {
        let h = DetectionClient::new("http://127.0.0.1:50051".into()).handle();
        assert_eq!(h.health().level, shared::health::HealthLevel::Disabled);
    }
}
