Skip to main content

Posture

Enum Posture 

Source
pub enum Posture {
    Accept,
    Reject(Action),
}
Expand description

What a policy does with every leaf that no rule named (D9, spec §2.6).

A policy has exactly one of these and cannot leave it unstated: “redact what is listed” and “redact everything except what is listed” are different enough that guessing between them is not something a redaction crate may do.

Example:

use er7_redact::{Action, Policy, Posture, Redactor};

// Accept by default: only what a rule names is redacted.
let listed = Policy::accept_all().with("PID-5", Action::redacted())?;

// Reject by default: only what a `keep` rule names survives.
let all_but = Policy::reject_all().with("PID-5", Action::Keep)?;

assert_eq!(listed.posture, Posture::Accept);
assert_eq!(all_but.posture, Posture::Reject(Action::redacted()));

let text = "MSH|^~\\&|LAB\rPID|1||9||SMITH";
let mut one = er7::parse(text)?;
let mut two = er7::parse(text)?;
Redactor::new(listed).redact(&mut one);
Redactor::new(all_but).redact(&mut two);

assert_eq!(one.to_er7(), "MSH|^~\\&|LAB\rPID|1||9||REDACTED");
assert_eq!(two.to_er7(), "MSH|^~\\&|REDACTED\rPID|REDACTED||REDACTED||SMITH");

Variants§

§

Accept

Accept by default: a leaf no rule named is left exactly as it is.

§

Reject(Action)

Reject by default: a leaf no rule named gets this action.

Reject(Action::Keep) is a contradiction — rejecting a value by leaving it alone — and Policy::posture normalises it to Posture::Accept, which is what it means.

Trait Implementations§

Source§

impl Clone for Posture

Source§

fn clone(&self) -> Posture

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Posture

Source§

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

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

impl Display for Posture

Source§

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

The policy file spelling, so a policy written out re-reads as itself (D18, spec §6.5).

Source§

impl Eq for Posture

Source§

impl PartialEq for Posture

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Posture

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.