34 lines
855 B
Rust
34 lines
855 B
Rust
use crate::dance_info::DanceInfo;
|
|
use crate::fetching::types::DanceInfoError;
|
|
|
|
mod scoringdance;
|
|
mod worldsdc;
|
|
pub mod types;
|
|
|
|
use async_trait::async_trait;
|
|
use std::sync::Arc;
|
|
|
|
#[async_trait]
|
|
pub trait WsdcFetcher: Send + Sync {
|
|
async fn fetch(&self, id: u32) -> Result<DanceInfo, DanceInfoError>;
|
|
}
|
|
|
|
pub struct WorldsdcFetcher;
|
|
pub struct ScoringDanceFetcher;
|
|
|
|
#[async_trait]
|
|
impl WsdcFetcher for WorldsdcFetcher {
|
|
async fn fetch(&self, id: u32) -> Result<DanceInfo, DanceInfoError> {
|
|
worldsdc::fetch_wsdc_info_wsdc(id).await
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl WsdcFetcher for ScoringDanceFetcher {
|
|
async fn fetch(&self, id: u32) -> Result<DanceInfo, DanceInfoError> {
|
|
scoringdance::fetch_wsdc_info_scoring_dance(id).await
|
|
}
|
|
}
|
|
|
|
/// Convenience alias for a shared, dynamic fetcher
|
|
pub type DynWsdcFetcher = Arc<dyn WsdcFetcher>; |