assemblyline_markings/
lib.rs

1#![warn(missing_docs, non_ascii_idents, trivial_numeric_casts,
2    unused_crate_dependencies, noop_method_call, single_use_lifetimes, trivial_casts,
3    unused_lifetimes, nonstandard_style, variant_size_differences)]
4#![deny(keyword_idents)]
5#![warn(clippy::missing_docs_in_private_items)]
6#![allow(clippy::needless_return, clippy::while_let_on_iterator, clippy::collapsible_else_if)]
7
8//! Library for manipulating and comparing classification strings based on configuration from Assemblyline.
9
10pub mod errors;
11pub mod config;
12pub mod classification;
13
14use std::sync::{Arc, Mutex};
15
16
17/// Mutex to hold a default parser the loaded system uses. 
18/// The classification engine is often treated as an aspect of the execution environment 
19/// that should be globally accessable. Rather than reloading a configuration file repeatedly or having 
20/// several different modules all track the same parser redundantly we will create a common mutex here.
21pub static DEFAULT_PARSER: Mutex<Option<Arc<classification::ClassificationParser>>> = Mutex::new(None);
22
23/// Load the assigned default parser
24pub fn get_default() -> Option<Arc<classification::ClassificationParser>> {
25    DEFAULT_PARSER.lock().unwrap().clone()
26}
27
28/// Set the default parser 
29pub fn set_default(parser: Arc<classification::ClassificationParser>)  {
30    *DEFAULT_PARSER.lock().unwrap() = Some(parser);
31}