pub struct ClassificationParser {
pub original_definition: ClassificationConfig,
/* private fields */
}Expand description
A parser to process classification banners
Fields§
§original_definition: ClassificationConfigThe config object used to build this parser
Implementations§
Source§impl ClassificationParser
impl ClassificationParser
Sourcepub fn load(path: &Path) -> Result<Self, Errors>
pub fn load(path: &Path) -> Result<Self, Errors>
Load a classification parser from a configuration file
Sourcepub fn new(definition: ClassificationConfig) -> Result<Self, Errors>
pub fn new(definition: ClassificationConfig) -> Result<Self, Errors>
Convert a config into a usable parser
Sourcepub fn get_normalized_classification_text(
&self,
parts: ParsedClassification,
long_format: bool,
skip_auto_select: bool,
) -> Result<String, Errors>
pub fn get_normalized_classification_text( &self, parts: ParsedClassification, long_format: bool, skip_auto_select: bool, ) -> Result<String, Errors>
Put the given components back togeather into a classification string default long_format = true default skip_auto_select = false
Sourcepub fn get_classification_level_text(
&self,
lvl_idx: i32,
long_format: bool,
) -> Result<String, Errors>
pub fn get_classification_level_text( &self, lvl_idx: i32, long_format: bool, ) -> Result<String, Errors>
convert a level number to a text form
Sourcepub fn get_classification_parts(
&self,
c12n: &str,
long_format: impl IBool,
get_dynamic_groups: impl IBool,
auto_select: impl IBool,
) -> Result<ParsedClassification, Errors>
pub fn get_classification_parts( &self, c12n: &str, long_format: impl IBool, get_dynamic_groups: impl IBool, auto_select: impl IBool, ) -> Result<ParsedClassification, Errors>
Break a classification into its parts
Sourcepub fn get_access_control_parts(
&self,
c12n: &str,
user_classification: bool,
) -> Result<Value, Errors>
pub fn get_access_control_parts( &self, c12n: &str, user_classification: bool, ) -> Result<Value, Errors>
Returns a dictionary containing the different access parameters Lucene needs to build it’s queries
Args: c12n: The classification to get the parts from user_classification: Is a user classification, (old default = false)
Sourcepub fn intersect_user_classification(
&self,
user_c12n_1: &str,
user_c12n_2: &str,
long_format: impl IBool,
) -> Result<String, Errors>
pub fn intersect_user_classification( &self, user_c12n_1: &str, user_c12n_2: &str, long_format: impl IBool, ) -> Result<String, Errors>
This function intersects two user classification to return the maximum classification that both user could see.
Args: user_c12n_1: First user classification user_c12n_2: Second user classification long_format: True/False in long format
Returns: Intersected classification in the desired format
Sourcepub fn is_accessible(&self, user_c12n: &str, c12n: &str) -> Result<bool, Errors>
pub fn is_accessible(&self, user_c12n: &str, c12n: &str) -> Result<bool, Errors>
Given a user classification, check if a user is allow to see a certain classification
Args: user_c12n: Maximum classification for the user c12n: Classification the user which to see , ignore_invalid: bool = False Returns: True is the user can see the classification
Sourcepub fn is_valid(&self, c12n: &str) -> bool
pub fn is_valid(&self, c12n: &str) -> bool
Check if the given classification banner can be interpreted
Sourcepub fn is_valid_skip_auto(&self, c12n: &str, skip_auto_select: bool) -> bool
pub fn is_valid_skip_auto(&self, c12n: &str, skip_auto_select: bool) -> bool
Performs a series of checks against a classification to make sure it is valid in it’s current form
Args: c12n: The classification we want to validate skip_auto_select: skip the auto selection phase
Returns: True if the classification is valid
Sourcepub fn max_classification(
&self,
c12n_1: &str,
c12n_2: &str,
long_format: impl IBool,
) -> Result<String, Errors>
pub fn max_classification( &self, c12n_1: &str, c12n_2: &str, long_format: impl IBool, ) -> Result<String, Errors>
Mixes to classification and returns to most restrictive form for them
Args: c12n_1: First classification c12n_2: Second classification long_format: True/False in long format, defaulted to true
Returns: The most restrictive classification that we could create out of the two
Sourcepub fn min_classification(
&self,
c12n_1: &str,
c12n_2: &str,
long_format: impl IBool,
) -> Result<String, Errors>
pub fn min_classification( &self, c12n_1: &str, c12n_2: &str, long_format: impl IBool, ) -> Result<String, Errors>
Mixes to classification and returns to least restrictive form for them
Args: c12n_1: First classification c12n_2: Second classification long_format: True/False in long format
Returns: The least restrictive classification that we could create out of the two
Sourcepub fn normalize_classification(&self, c12n: &str) -> Result<String, Errors>
pub fn normalize_classification(&self, c12n: &str) -> Result<String, Errors>
call normalize_classification_options with default arguments
Sourcepub fn normalize_classification_options(
&self,
c12n: &str,
options: NormalizeOptions,
) -> Result<String, Errors>
pub fn normalize_classification_options( &self, c12n: &str, options: NormalizeOptions, ) -> Result<String, Errors>
Normalize a given classification by applying the rules defined in the classification definition. This function will remove any invalid parts and add missing parts to the classification. It will also ensure that the display of the classification is always done the same way
Args: c12n: Classification to normalize long_format: True/False in long format skip_auto_select: True/False skip group auto adding, use True when dealing with user’s classifications
Returns: A normalized version of the original classification
Sourcepub fn build_user_classification(
&self,
c12n_1: &str,
c12n_2: &str,
long_format: impl IBool,
) -> Result<String, Errors>
pub fn build_user_classification( &self, c12n_1: &str, c12n_2: &str, long_format: impl IBool, ) -> Result<String, Errors>
Mixes two classification and return the classification marking that would give access to the most data
Args: c12n_1: First classification c12n_2: Second classification long_format: True/False in long format
Returns: The classification that would give access to the most data
Sourcepub fn levels(&self) -> &HashMap<i32, ClassificationLevel>
pub fn levels(&self) -> &HashMap<i32, ClassificationLevel>
Get all the levels found in this config
Sourcepub fn restricted(&self) -> &str
pub fn restricted(&self) -> &str
Get the classification string predefined as maximally restricted
Sourcepub fn unrestricted(&self) -> &str
pub fn unrestricted(&self) -> &str
Get the classification string predefined as minimally restricted
Trait Implementations§
Source§impl Debug for ClassificationParser
impl Debug for ClassificationParser
Source§impl Default for ClassificationParser
impl Default for ClassificationParser
Source§fn default() -> ClassificationParser
fn default() -> ClassificationParser
Source§impl PartialEq for ClassificationParser
impl PartialEq for ClassificationParser
impl StructuralPartialEq for ClassificationParser
Auto Trait Implementations§
impl Freeze for ClassificationParser
impl RefUnwindSafe for ClassificationParser
impl Send for ClassificationParser
impl Sync for ClassificationParser
impl Unpin for ClassificationParser
impl UnsafeUnpin for ClassificationParser
impl UnwindSafe for ClassificationParser
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more