pub struct BoolMask {
pub policy_index: usize,
pub name: String,
pub mask: String,
pub default: Option<bool>,
pub on_conflict: OnConflict,
}Expand description
Represents a boolean field mask for policy application.
A BoolMask handles the extraction and conflict resolution of boolean values from unstructured data based on policy rules.
Fields§
§policy_index: usizeIndex of the policy this mask belongs to
name: StringOriginal field name from the policy definition
mask: StringMasked field name unlikely to be in LLM training data
default: Option<bool>Default value when the field is not present
on_conflict: OnConflictStrategy for resolving conflicts when multiple policies set different values
Implementations§
Source§impl BoolMask
impl BoolMask
Sourcepub fn new(
policy_index: usize,
name: String,
mask: String,
default: Option<bool>,
on_conflict: OnConflict,
) -> Self
pub fn new( policy_index: usize, name: String, mask: String, default: Option<bool>, on_conflict: OnConflict, ) -> Self
Create a new BoolMask with the specified parameters.
§Arguments
policy_index- The index of the policy this mask belongs toname- The original field name from the policy definitionmask- The masked field name unlikely to be in LLM training datadefault- The default boolean value when field is absenton_conflict- Strategy for resolving conflicts between policies
§Example
use policyai::{BoolMask, OnConflict};
let mask = BoolMask::new(
1,
"urgent".to_string(),
"field_abc123".to_string(),
Some(false),
OnConflict::Agreement
);Sourcepub fn apply_to(&self, ir: &Value, report: &mut Report)
pub fn apply_to(&self, ir: &Value, report: &mut Report)
Apply this boolean mask to intermediate representation data.
Extracts the boolean value from the IR and reports it to the given Report if it matches the expected value, otherwise reports the default.
§Arguments
ir- The intermediate representation JSON from the LLMreport- The report to write results and errors to
§Example
let mask = BoolMask::new(1, "urgent".to_string(), "field_abc".to_string(), None, OnConflict::Default);
let ir = serde_json::json!({"field_abc": true});
let mut report = Report::new(vec![], vec![], vec![], vec![], vec![], vec![], vec![]);
mask.apply_to(&ir, &mut report);Trait Implementations§
Source§impl<'de> Deserialize<'de> for BoolMask
impl<'de> Deserialize<'de> for BoolMask
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for BoolMask
impl RefUnwindSafe for BoolMask
impl Send for BoolMask
impl Sync for BoolMask
impl Unpin for BoolMask
impl UnwindSafe for BoolMask
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