pub struct ValidatedConfigWatcher<T>{ /* private fields */ }Expand description
Configuration watcher with custom validation
Like ConfigWatcher, but also runs custom validation logic before applying changes.
§Example
use mecha10::config_watcher::ValidatedConfigWatcher;
use mecha10::config::Validate;
#[derive(Debug, Clone, Deserialize)]
struct AppConfig {
port: u16,
}
impl Validate for AppConfig {
fn validate(&self) -> Result<()> {
if self.port < 1024 {
return Err(Mecha10Error::Configuration(
"Port must be >= 1024".to_string()
));
}
Ok(())
}
}
let watcher = ValidatedConfigWatcher::new("config.yaml", |config: &AppConfig| {
println!("Valid config loaded!");
})?;Implementations§
Auto Trait Implementations§
impl<T> Freeze for ValidatedConfigWatcher<T>
impl<T> !RefUnwindSafe for ValidatedConfigWatcher<T>
impl<T> Send for ValidatedConfigWatcher<T>
impl<T> Sync for ValidatedConfigWatcher<T>
impl<T> Unpin for ValidatedConfigWatcher<T>
impl<T> !UnwindSafe for ValidatedConfigWatcher<T>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more