Files
dancing-teacher-info/src/fetching/mod.rs
Lukas Wölfer b869842aa3
All checks were successful
Release / build_release (push) Successful in 2m21s
Rust / build_and_test (push) Successful in 1m13s
Moved around types
2026-01-17 22:24:00 +01:00

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>;