use std::fmt::Debug;
use std::pin::Pin;
use futures_core::Stream;
use tea_protocol::ModelId;
use crate::{ModelCancellation, ModelEvent, ModelRequest, ModelSpec, ProviderId};
pub trait ModelStream: Stream<Item = ModelEvent> + Send {}
impl<T> ModelStream for T where T: Stream<Item = ModelEvent> + Send {}
pub type BoxModelStream = Pin<Box<dyn ModelStream + 'static>>;
pub trait ModelProvider: Debug + Send + Sync {
fn provider_id(&self) -> &ProviderId;
fn models(&self) -> &[ModelSpec];
fn model(&self, model_id: &ModelId) -> Option<&ModelSpec> {
self.models()
.iter()
.find(|model| model.model_id() == model_id)
}
fn stream(&self, request: ModelRequest, cancellation: ModelCancellation) -> BoxModelStream;
}