pub struct ReferenceCatalog {
pub references: Vec<KnownReference>,
pub md5_to_refs: HashMap<String, Vec<usize>>,
pub name_length_to_refs: HashMap<(String, u64), Vec<usize>>,
pub alias_length_to_refs: HashMap<(String, u64), Vec<usize>>,
/* private fields */
}Expand description
The main reference catalog with indexes
Fields§
§references: Vec<KnownReference>All known references
md5_to_refs: HashMap<String, Vec<usize>>Index: MD5 -> indices of references containing this MD5
name_length_to_refs: HashMap<(String, u64), Vec<usize>>Index: (exact_name, length) -> indices of references
alias_length_to_refs: HashMap<(String, u64), Vec<usize>>Index: (alias, length) -> indices of references
Separate from name_length_to_refs to distinguish primary names from aliases
Implementations§
Source§impl ReferenceCatalog
impl ReferenceCatalog
Sourcepub fn load_embedded() -> Result<Self, CatalogError>
pub fn load_embedded() -> Result<Self, CatalogError>
Load the embedded default catalog
§Errors
Returns CatalogError::Json if the embedded catalog is invalid.
Sourcepub fn load_from_file(path: &Path) -> Result<Self, CatalogError>
pub fn load_from_file(path: &Path) -> Result<Self, CatalogError>
Load catalog from a JSON file
§Errors
Returns CatalogError::Io if the file cannot be read, or
CatalogError::Json if parsing fails.
Sourcepub fn from_json(json: &str) -> Result<Self, CatalogError>
pub fn from_json(json: &str) -> Result<Self, CatalogError>
Sourcepub fn add_reference(&mut self, reference: KnownReference)
pub fn add_reference(&mut self, reference: KnownReference)
Add a reference to the catalog
Sourcepub fn get(&self, id: &ReferenceId) -> Option<&KnownReference>
pub fn get(&self, id: &ReferenceId) -> Option<&KnownReference>
Get a reference by ID
Sourcepub fn find_by_signature(&self, signature: &str) -> Option<&KnownReference>
pub fn find_by_signature(&self, signature: &str) -> Option<&KnownReference>
Find exact match by signature
Sourcepub fn to_json(&self) -> Result<String, CatalogError>
pub fn to_json(&self) -> Result<String, CatalogError>
Trait Implementations§
Source§impl Debug for ReferenceCatalog
impl Debug for ReferenceCatalog
Auto Trait Implementations§
impl Freeze for ReferenceCatalog
impl RefUnwindSafe for ReferenceCatalog
impl Send for ReferenceCatalog
impl Sync for ReferenceCatalog
impl Unpin for ReferenceCatalog
impl UnwindSafe for ReferenceCatalog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more