pub struct RedactionPolicy {
pub schema: String,
pub classes: BTreeMap<FieldClass, Action>,
pub fields: Vec<FieldOverride>,
pub content_events: Vec<String>,
}Expand description
A redaction policy, rustev.redaction/1 (3.4.1). Parse it with
RedactionPolicy::parse_validated; a policy that has not passed
RedactionPolicy::validate is never applied.
Fields§
§schema: String§classes: BTreeMap<FieldClass, Action>Class-wide actions; an unnamed class takes its default (3.4.3).
fields: Vec<FieldOverride>Per-field overrides, each naming one catalogue field exactly.
content_events: Vec<String>Catalogue content fields whose GenAI content events may be emitted.
Implementations§
Source§impl RedactionPolicy
impl RedactionPolicy
Sourcepub fn parse_validated(bytes: &[u8]) -> Result<Self, PolicyError>
pub fn parse_validated(bytes: &[u8]) -> Result<Self, PolicyError>
Parse and validate (3.4.1, 3.4.2).
Sourcepub fn validate(&self) -> Result<(), PolicyError>
pub fn validate(&self) -> Result<(), PolicyError>
Every refusal of 3.4.2, naming the entry; the first one found.
Sourcepub fn policy_id(&self) -> RedactionPolicyId
pub fn policy_id(&self) -> RedactionPolicyId
The policy’s identity, sha256: of its canonical bytes (3.4.1).
Sourcepub fn class_action(&self, class: FieldClass) -> Action
pub fn class_action(&self, class: FieldClass) -> Action
The class action: the classes entry, else the class default.
Sourcepub fn action(&self, field: &str, class: FieldClass) -> Action
pub fn action(&self, field: &str, class: FieldClass) -> Action
The effective action for field holding a value of class (3.4.4):
allow for a fixed field, else its fields override, else its
class’s entry, else the class default.
Sourcepub fn reader_action(&self, field: &str) -> Option<Action>
pub fn reader_action(&self, field: &str) -> Option<Action>
The action a reader that does not know the value’s class applies to
field (3.11.3): a fixed field is allow; an override applies as
written; a field with a fixed class takes that class’s action; a
field under the lineage rule (3.3.2) takes the most withholding
action among every class the rule can assign, so the reader never
shows more than the policy allows for the value’s actual class.
None for a key outside the catalogue.
Sourcepub fn needs_key(&self) -> bool
pub fn needs_key(&self) -> bool
Whether any action this policy can apply is digest, which needs a
key (3.4.5).
Sourcepub fn view(&self, field: &str, attr: &TraceAttr) -> View
pub fn view(&self, field: &str, attr: &TraceAttr) -> View
How a reader holding no key shows one attribute written as attr
under the key field (3.11.3): drop withholds it; allow shows it
as written; digest shows it only if the line marks it digest;
truncate{bytes} cuts a value marked allow or truncated and shows
a digest as is. A key outside the catalogue is never shown.
Trait Implementations§
Source§impl Clone for RedactionPolicy
impl Clone for RedactionPolicy
Source§impl Debug for RedactionPolicy
impl Debug for RedactionPolicy
Source§impl Default for RedactionPolicy
impl Default for RedactionPolicy
Source§impl<'de> Deserialize<'de> for RedactionPolicy
impl<'de> Deserialize<'de> for RedactionPolicy
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>,
Source§impl Document for RedactionPolicy
impl Document for RedactionPolicy
Source§const SCHEMA: &'static str = REDACTION
const SCHEMA: &'static str = REDACTION
Source§const LIMITS: ParseLimits = DESCRIPTOR_V1
const LIMITS: ParseLimits = DESCRIPTOR_V1
Source§fn parse(bytes: &[u8]) -> Result<Self, DocumentError>
fn parse(bytes: &[u8]) -> Result<Self, DocumentError>
Source§fn record_canonical(&self) -> Result<Vec<u8>, CanonicalError>where
Self: PartialEq,
fn record_canonical(&self) -> Result<Vec<u8>, CanonicalError>where
Self: PartialEq,
Source§fn record_digest(&self) -> Result<ContentDigest, CanonicalError>where
Self: PartialEq,
fn record_digest(&self) -> Result<ContentDigest, CanonicalError>where
Self: PartialEq,
sha256(SCHEMA || 0x00 || record canonical bytes) (spec 004, 3.1.6).
Equal to the identity of an identified document.impl Eq for RedactionPolicy
Source§impl Identified for RedactionPolicy
impl Identified for RedactionPolicy
type Id = RedactionPolicyId
Source§impl JsonSchema for RedactionPolicy
impl JsonSchema for RedactionPolicy
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more