codama_stores/
root_store.rs

1use crate::CrateStore;
2use codama_errors::{CodamaResult, IteratorCombineErrors};
3use std::path::Path;
4
5#[derive(Debug, PartialEq)]
6pub struct RootStore {
7    pub crates: Vec<CrateStore>,
8}
9
10impl RootStore {
11    pub fn load<P: AsRef<Path>>(path: P) -> CodamaResult<Self> {
12        Self::load_all(&[path])
13    }
14
15    pub fn load_all<P: AsRef<Path>>(paths: &[P]) -> CodamaResult<Self> {
16        Ok(Self {
17            crates: paths
18                .iter()
19                .map(CrateStore::load)
20                .collect_and_combine_errors()?,
21        })
22    }
23
24    pub fn hydrate(tt: proc_macro2::TokenStream) -> CodamaResult<Self> {
25        Ok(Self {
26            crates: vec![CrateStore::hydrate(tt)?],
27        })
28    }
29}