macro_rules! one_of {
(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 alternatives, without type erasure.
A flat, semicolon-separated sequence of policy expressions builds a try-each-until-one-succeeds
chain (the first alternative that meets the requirements wins; if every alternative fails, the
reported failure reason joins every alternative’s reason), using nested OneOfTuple2 values —
this is the one_of! counterpart to policy!’s AND-chain.
use x509_validator::one_of;
use x509_validator::rfc5280::{RFC5280Policy, VersionPolicy};
let built = one_of! {
RFC5280Policy::new(validation_time);
VersionPolicy
};