1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use crate::api::items::Items;
use crate::api::recipes::Recipes;
use crate::models::version::Version;
use std::sync::Arc;

#[cfg(test)]
mod tests;

pub mod items;
mod recipes;
pub mod versions;

pub struct Api {
    pub version: Arc<Version>,
    pub items: Items,
    pub recipes: Recipes,
}

impl Api {
    pub fn new(version: Version) -> Self {
        let version = Arc::new(version);
        Self {
            version: Arc::clone(&version),
            items: Items::new(Arc::clone(&version)),
            recipes: Recipes::new(Arc::clone(&version)),
        }
    }
}