use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex, RwLock};
use crate::{ConfigError, LoadedConfig};
mod core;
mod model;
#[cfg(feature = "watch")]
mod native;
mod polling;
mod snapshot;
mod summary;
mod sync;
mod watch;
pub use self::model::{ReloadEvent, ReloadFailure, ReloadFailurePolicy, ReloadOptions};
#[cfg(feature = "watch")]
pub use self::native::NativeWatcher;
pub use self::polling::PollingWatcher;
pub use self::summary::{ConfigChange, ReloadSummary};
type LoaderFn<T> = dyn Fn() -> Result<LoadedConfig<T>, ConfigError> + Send + Sync + 'static;
pub struct ReloadHandle<T> {
state: Arc<RwLock<LoadedConfig<T>>>,
loader: Arc<LoaderFn<T>>,
last_error: Arc<Mutex<Option<String>>>,
subscribers: Arc<Mutex<Vec<Sender<ReloadEvent>>>>,
}