use crate::error::Result;
use crate::schema::{InferenceRequest, InferenceResponse};

pub mod burn;
pub mod dlrm;
pub mod mlp;
#[cfg(feature = "torch")]
pub mod torch_dlrm;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BackendMetadata {
    pub name: String,
    pub kind: String,
}

pub trait InferenceBackend: Send + Sync + 'static {
    fn metadata(&self) -> BackendMetadata;

    fn infer(&self, request: InferenceRequest) -> Result<InferenceResponse>;

    /// Run inference on a batch of requests. Default impl calls `infer` one-by-one.
    /// Override for backends that can amortise compute across a batch.
    fn infer_batch(&self, requests: Vec<InferenceRequest>) -> Vec<Result<InferenceResponse>> {
        requests.into_iter().map(|r| self.infer(r)).collect()
    }
}
