Skip to main content

wowlab_engine_adapter_data/local/
mod.rs

1mod csv;
2
3use wowlab_engine_ports::ResolverError;
4
5#[rustfmt::skip]
6pub use csv::LocalCsvResolver;
7
8pub(crate) fn read_rotation_from_disk(
9    data_dir: &wowlab_fs::path::Path,
10    rotation_id: &str,
11) -> Result<String, ResolverError> {
12    let exact_path = data_dir.join("rotations").join(rotation_id);
13
14    match wowlab_fs::file::read_text(&exact_path) {
15        Ok(source) => return Ok(source),
16        Err(error) if error.is_not_found() => {}
17        Err(error) => return Err(ResolverError::filesystem(error)),
18    }
19
20    let json_path = data_dir
21        .join("rotations")
22        .join(format!("{rotation_id}.json"));
23
24    Ok(wowlab_fs::file::read_text(&json_path)?)
25}