Cleaned up project structure
Some checks failed
Rust / build_and_test (push) Failing after 1m16s

This commit is contained in:
Lukas Wölfer
2026-01-17 21:58:29 +01:00
parent 7baff3a50c
commit 681cc0f59d
17 changed files with 253 additions and 162 deletions

39
src/fetching/mod.rs Normal file
View File

@@ -0,0 +1,39 @@
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>;
/// Back-compat helper that uses the `WorldsdcFetcher`.
pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
WorldsdcFetcher.fetch(id).await
}