Skip to main content

policy

Macro policy 

Source
macro_rules! policy {
    (if ($cond:expr) { $then:expr } else { $else_:expr }; $($rest:tt)+) => { ... };
    (if ($cond:expr) { $then:expr } else { $else_:expr }) => { ... };
    (if ($cond:expr) { $body:expr }; $($rest:tt)+) => { ... };
    (if ($cond:expr) { $body:expr }) => { ... };
    ($first:expr; $($rest:tt)+) => { ... };
    ($only:expr) => { ... };
}
Expand description

A DSL for constructing a ValidationPolicy out of other ValidationPolicy values, without type erasure.

A flat, semicolon-separated sequence of policy expressions builds an AND-chain (every listed policy must be met), using nested Tuple2 values:

use x509_validator::policy;
use x509_validator::rfc5280::{RFC5280Policy, VersionPolicy};

let built = policy! {
    RFC5280Policy::new(validation_time);
    VersionPolicy
};