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§
impl Eq for Posture
impl StructuralPartialEq for Posture
Auto Trait Implementations§
impl Freeze for Posture
impl RefUnwindSafe for Posture
impl Send for Posture
impl Sync for Posture
impl Unpin for Posture
impl UnsafeUnpin for Posture
impl UnwindSafe for Posture
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