serde_lwjson/
lwjson.rs

1use std::collections::HashMap;
2
3include!(concat!(env!("OUT_DIR"), "/lwjson.rs"));
4
5pub trait HelperMethods {
6    fn build_repo_map(&self) -> HashMap<&str, &Repository>;
7    fn build_artifacts_map(&self) -> HashMap<&str, &Artifact>;
8}
9
10impl HelperMethods for Document {
11    fn build_repo_map(&self) -> HashMap<&str, &Repository> {
12        let mut result = HashMap::new();
13        for repositories in &self.repositories {
14            for repo in repositories {
15                result.insert(repo.id.as_str(), repo);
16            }
17        }
18        result
19    }
20
21    fn build_artifacts_map(&self) -> HashMap<&str, &Artifact> {
22        let mut result = HashMap::new();
23        for artifacts in &self.artifacts {
24            for artifact in artifacts {
25                result.insert(artifact.id.as_str(), artifact);
26            }
27        }
28        result
29    }
30}