///|
pub struct GuardConfig {
policy : VerificationPolicy
router : EventRouter
state : GuardState
} derive(Eq, Debug)
///|
pub fn GuardConfig::new(
policy : VerificationPolicy,
router : EventRouter,
state? : GuardState = GuardState::empty(),
) -> GuardConfig {
{ policy, router, state }
}
///|
pub fn GuardConfig::default() -> GuardConfig {
GuardConfig::new(VerificationPolicy::default(), default_router())
}
///|
pub fn GuardConfig::for_provider(
provider_name : String,
secret : String,
now : Int,
) -> GuardConfig {
GuardConfig::new(
policy_for_provider(provider_name, secret, now),
default_router(),
)
}
///|
pub fn GuardConfig::with_router(
self : GuardConfig,
router : EventRouter,
) -> GuardConfig {
{ ..self, router, }
}
///|
pub fn GuardConfig::with_state(
self : GuardConfig,
state : GuardState,
) -> GuardConfig {
{ ..self, state, }
}
///|
pub fn GuardConfig::with_policy(
self : GuardConfig,
policy : VerificationPolicy,
) -> GuardConfig {
{ ..self, policy, }
}
///|
pub fn validate_config(config : GuardConfig) -> GuardQualityReport {
evaluate_guard_config(config.policy, config.router)
}
///|
pub fn config_summary(config : GuardConfig) -> String {
let quality = validate_config(config)
"provider=\{config.policy.provider.name} handlers=\{config.router.handlers().length()} ready=\{quality.is_ready()}"
}