fn from_sdk_atoms<T, U>(
        path_prefix: PathBuf,
        atoms: SdkAtoms,
        get_meta: T,
        version: SdkVersion,
    ) -> Result<Self>
    where
        T: Fn(&PathBuf) -> Result<BufReader<U>>,
        U: io::Read,
    {
        let mut metas = Vec::new();
        let mut real_paths = HashMap::new();

        for atom in atoms.atoms.iter() {
            for file in atom.files.iter() {
                real_paths.insert(file.destination.clone(), file.source.clone());
            }

            let meta_file_name = real_paths
                .get(&atom.meta)
                .ok_or(anyhow!("Atom did not specify source for its metadata."))?;
            let full_meta_path = path_prefix.join(meta_file_name);

            let reader = get_meta(&full_meta_path);
            let json_metas = serde_json::from_reader(reader?);

            match json_metas {
                Ok(result) => metas.push(result),
                Err(e) => {
                    return Err(anyhow!("Can't read json file {:?}: {:?}", full_meta_path, e))
                }
            }
        }

        Ok(Sdk { path_prefix, metas, real_paths: RealPaths::Map(real_paths), version })
    }
/// Allocates a new Sdk using the given atoms.
///
/// All the meta files specified in the atoms are loaded.
/// The creation succeed only if all the meta files have been loaded successfully.
Allocates a new Sdk using the given atoms.
All the meta files specified in the atoms are loaded.
The creation succeed only if all the meta files have been loaded successfully.
Allocates a new Sdk using the given atoms . All the meta files specified in the atoms are loaded . The creation succeed only if all the meta files have been loaded successfully .
fn from_sdk_atoms<T, U>(
        path_prefix: PathBuf,
        atoms: SdkAtoms,
        get_meta: T,
        version: SdkVersion,
    ) -> Result<Self>
    where
        T: Fn(&PathBuf) -> Result<BufReader<U>>,
        U: io::Read,
    {
        let mut metas = Vec::new();
        let mut real_paths = HashMap::new();
        for atom in atoms.atoms.iter() {
            for file in atom.files.iter() {
                real_paths.insert(file.destination.clone(), file.source.clone());
            }
            let meta_file_name = real_paths
                .get(&atom.meta)
                .ok_or(anyhow!("Atom did not specify source for its metadata."))?;
            let full_meta_path = path_prefix.join(meta_file_name);
            let reader = get_meta(&full_meta_path);
            let json_metas = serde_json::from_reader(reader?);
            match json_metas {
                Ok(result) => metas.push(result),
                Err(e) => {
                    return Err(anyhow!("Can't read json file {:?}: {:?}", full_meta_path, e))
                }
            }
        }
        Ok(Sdk { path_prefix, metas, real_paths: RealPaths::Map(real_paths), version })
    }
fn from_sdk_atoms < T , U > ( path_prefix : PathBuf , atoms : SdkAtoms , get_meta : T , version : SdkVersion , ) -> Result < Self > where T : Fn ( & PathBuf ) -> Result < BufReader < U > > , U : io :: Read , { let mut metas = Vec :: new ( ) ; let mut real_paths = HashMap :: new ( ) ; for atom in atoms . atoms . iter ( ) { for file in atom . files . iter ( ) { real_paths . insert ( file . destination . clone ( ) , file . source . clone ( ) ) ; } let meta_file_name = real_paths . get ( & atom . meta ) . ok_or ( anyhow ! ( " " ) ) ? ; let full_meta_path = path_prefix . join ( meta_file_name ) ; let reader = get_meta ( & full_meta_path ) ; let json_metas = serde_json :: from_reader ( reader ? ) ; match json_metas { Ok ( result ) => metas . push ( result ) , Err ( e ) => { return Err ( anyhow ! ( " " full_meta_path e ) ) } } } Ok ( Sdk { path_prefix , metas , real_paths : RealPaths :: Map ( real_paths ) , version } ) }
Allocates a new Sdk using the given atoms.
Allocates a new Sdk using the given atoms .
path_prefix
PathBuf
atoms
SdkAtoms
get_meta
T
version
SdkVersion
path_prefix
PathBuf
atoms
SdkAtoms
get_meta
T
version
SdkVersion