mod cache;
mod distil;
mod http;
mod resolve;
use super::{Fetch, QuirksError};
pub(crate) use crate::test_support::MODELS_DEV_DOCUMENT as DOCUMENT;
pub(crate) const NO_ENDPOINTS: &str = r#"{
"anthropic": { "id": "anthropic", "api": null, "models": { "fable-5": { "id": "fable-5" } } }
}"#;
pub(crate) struct Canned {
document: Option<String>,
pub calls: std::cell::Cell<usize>,
}
impl Canned {
pub fn serving(body: &str) -> Self {
Self {
document: Some(body.to_string()),
calls: std::cell::Cell::new(0),
}
}
pub fn offline() -> Self {
Self {
document: None,
calls: std::cell::Cell::new(0),
}
}
}
impl Fetch for Canned {
async fn document(&self) -> Result<String, QuirksError> {
self.calls.set(self.calls.get() + 1);
match &self.document {
Some(body) => Ok(body.clone()),
None => Err(QuirksError::Transport("the stub is offline".to_string())),
}
}
}