()
| 87 | |
| 88 | impl OidTable { |
| 89 | fn build() -> Self { |
| 90 | let entries = build_oid_entries(); |
| 91 | let mut nid_to_idx = HashMap::with_capacity(entries.len()); |
| 92 | let mut short_name_to_idx = HashMap::with_capacity(entries.len()); |
| 93 | let mut long_name_to_idx = HashMap::with_capacity(entries.len()); |
| 94 | let mut oid_str_to_idx = HashMap::with_capacity(entries.len()); |
| 95 | |
| 96 | for (idx, entry) in entries.iter().enumerate() { |
| 97 | nid_to_idx.insert(entry.nid, idx); |
| 98 | short_name_to_idx.insert(entry.short_name, idx); |
| 99 | long_name_to_idx.insert(entry.long_name.to_lowercase(), idx); |
| 100 | oid_str_to_idx.insert(entry.oid_string(), idx); |
| 101 | } |
| 102 | |
| 103 | Self { |
| 104 | entries, |
| 105 | nid_to_idx, |
| 106 | short_name_to_idx, |
| 107 | long_name_to_idx, |
| 108 | oid_str_to_idx, |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | pub fn find_by_nid(&self, nid: i32) -> Option<&OidEntry> { |
| 113 | self.nid_to_idx.get(&nid).map(|&idx| &self.entries[idx]) |
no test coverage detected