Skip to main content

ClassificationParser

Struct ClassificationParser 

Source
pub struct ClassificationParser {
    pub original_definition: ClassificationConfig,
    /* private fields */
}
Expand description

A parser to process classification banners

Fields§

§original_definition: ClassificationConfig

The config object used to build this parser

Implementations§

Source§

impl ClassificationParser

Source

pub fn load(path: &Path) -> Result<Self, Errors>

Load a classification parser from a configuration file

Source

pub fn new(definition: ClassificationConfig) -> Result<Self, Errors>

Convert a config into a usable parser

Source

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

Source

pub fn get_classification_level_text( &self, lvl_idx: i32, long_format: bool, ) -> Result<String, Errors>

convert a level number to a text form

Source

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

Source

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)

Source

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

Source

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

Source

pub fn is_valid(&self, c12n: &str) -> bool

Check if the given classification banner can be interpreted

Source

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

Source

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

Source

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

Source

pub fn normalize_classification(&self, c12n: &str) -> Result<String, Errors>

call normalize_classification_options with default arguments

Source

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

Source

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

Source

pub fn levels(&self) -> &HashMap<i32, ClassificationLevel>

Get all the levels found in this config

Source

pub fn restricted(&self) -> &str

Get the classification string predefined as maximally restricted

Source

pub fn unrestricted(&self) -> &str

Get the classification string predefined as minimally restricted

Trait Implementations§

Source§

impl Debug for ClassificationParser

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClassificationParser

Source§

fn default() -> ClassificationParser

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ClassificationParser

Source§

fn eq(&self, other: &ClassificationParser) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ClassificationParser

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.