mod beta;
mod http;
mod nightly;
mod stable;
use crate::domain::RustRelease;
use crate::infra::Config;
use anyhow::Result;
use async_trait::async_trait;
#[async_trait]
pub trait ReleaseFetcher: Send + Sync {
fn channel_name(&self) -> &str;
fn source_description(&self) -> &str;
async fn fetch(&self, config: &Config) -> Result<Vec<RustRelease>>;
}
pub fn create_fetcher(channel: &str, full: bool, days: u32) -> Result<Box<dyn ReleaseFetcher>> {
match channel {
"stable" => Ok(Box::new(stable::StableFetcher::new(full))),
"beta" => Ok(Box::new(beta::BetaFetcher::new(days))),
"nightly" => Ok(Box::new(nightly::NightlyFetcher::new(days))),
_ => anyhow::bail!("Unknown channel: '{channel}'. Must be one of: stable, beta, nightly"),
}
}