#![allow(missing_docs)]
use aws_smithy_types::config_bag::{Storable, StoreReplace};
use std::time::Duration;
const DEFAULT_GRACE_PERIOD: Duration = Duration::from_secs(5);
#[derive(Clone, Debug)]
pub struct StalledStreamProtectionConfig {
is_enabled: bool,
grace_period: Duration,
}
impl StalledStreamProtectionConfig {
pub fn enabled() -> Builder {
Builder {
is_enabled: Some(true),
grace_period: None,
}
}
pub fn disabled() -> Self {
Self {
is_enabled: false,
grace_period: DEFAULT_GRACE_PERIOD,
}
}
pub fn is_enabled(&self) -> bool {
self.is_enabled
}
pub fn grace_period(&self) -> Duration {
self.grace_period
}
}
#[derive(Clone, Debug)]
pub struct Builder {
is_enabled: Option<bool>,
grace_period: Option<Duration>,
}
impl Builder {
pub fn grace_period(mut self, grace_period: Duration) -> Self {
self.grace_period = Some(grace_period);
self
}
pub fn set_grace_period(&mut self, grace_period: Option<Duration>) -> &mut Self {
self.grace_period = grace_period;
self
}
pub fn is_enabled(mut self, is_enabled: bool) -> Self {
self.is_enabled = Some(is_enabled);
self
}
pub fn set_is_enabled(&mut self, is_enabled: Option<bool>) -> &mut Self {
self.is_enabled = is_enabled;
self
}
pub fn build(self) -> StalledStreamProtectionConfig {
StalledStreamProtectionConfig {
is_enabled: self.is_enabled.unwrap_or_default(),
grace_period: self.grace_period.unwrap_or(DEFAULT_GRACE_PERIOD),
}
}
}
impl From<StalledStreamProtectionConfig> for Builder {
fn from(config: StalledStreamProtectionConfig) -> Self {
Builder {
is_enabled: Some(config.is_enabled),
grace_period: Some(config.grace_period),
}
}
}
impl Storable for StalledStreamProtectionConfig {
type Storer = StoreReplace<Self>;
}