pub struct ConfigHandle<T> { /* private fields */ }Expand description
Live, cloneable handle to a loaded config value.
Reads are lock-free via ArcSwap. Writes go through WriteGuard, which
atomically updates the in-memory state on drop and optionally persists to
the config file (watcher mode only).
Clone the handle freely — all clones share the same live value.
Implementations§
Source§impl<T: ConfigSchema> ConfigHandle<T>
impl<T: ConfigSchema> ConfigHandle<T>
Source§impl<T: ConfigSchema + Clone + Serialize> ConfigHandle<T>
impl<T: ConfigSchema + Clone + Serialize> ConfigHandle<T>
Sourcepub fn write_back(
initial: T,
path: impl Into<PathBuf>,
format: impl Format + Send + Sync + 'static,
) -> Self
pub fn write_back( initial: T, path: impl Into<PathBuf>, format: impl Format + Send + Sync + 'static, ) -> Self
Write-back mode: no file watcher, but every WriteGuard drop persists to path.
Use this when you want config.write() to auto-save without spinning up a
hot-reload thread.
Sourcepub fn write(&self) -> WriteGuard<T>
pub fn write(&self) -> WriteGuard<T>
Return a write guard. On drop the guard:
- Serializes the modified value and writes it to the config file (watcher mode).
- Atomically swaps it into the
ArcSwapso all readers see the new value.
In manual mode only step 2 happens (no file path is stored).
Trait Implementations§
Source§impl<T> Clone for ConfigHandle<T>
impl<T> Clone for ConfigHandle<T>
Source§impl<T: ConfigSchema> From<T> for ConfigHandle<T>
impl<T: ConfigSchema> From<T> for ConfigHandle<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ConfigHandle<T>
impl<T> !UnwindSafe for ConfigHandle<T>
impl<T> Freeze for ConfigHandle<T>
impl<T> Send for ConfigHandle<T>
impl<T> Sync for ConfigHandle<T>
impl<T> Unpin for ConfigHandle<T>
impl<T> UnsafeUnpin for ConfigHandle<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