pub struct LazyConfig<T: Copy + Send + Sync + 'static> { /* private fields */ }Implementations§
Source§impl<T: Copy + Send + Sync + 'static> LazyConfig<T>
impl<T: Copy + Send + Sync + 'static> LazyConfig<T>
pub fn create(path: impl AsRef<Path>) -> Result<Self, LazyConfigError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, LazyConfigError>
Sourcepub fn get_or_fetch<F: FnOnce() -> T>(&self, fetcher: F) -> T
pub fn get_or_fetch<F: FnOnce() -> T>(&self, fetcher: F) -> T
Get the value if cached. Otherwise, race to be the canonical
fetcher: the CAS winner runs fetcher and publishes; CAS
losers block until the winner publishes, then return the
canonical value.
Across all processes mapping this file, fetcher runs at
most once per process AND only one process’s result becomes
canonical. (In practice with the CAS-then-fetch protocol
from SharedOnceCell::get_or_init, the winner is the
only one to actually run the fetcher.)
Sourcepub fn force_set(&self, value: T) -> bool
pub fn force_set(&self, value: T) -> bool
Force-set the value without going through a fetcher. Useful
for testing or for an admin-set-config workflow. Returns
true if this caller’s value became canonical (it won the
CAS), false when the cell was already initialised.
pub fn flush(&self) -> Result<(), LazyConfigError>
Sourcepub fn flush_async(&self) -> Result<(), LazyConfigError>
pub fn flush_async(&self) -> Result<(), LazyConfigError>
Non-blocking flush: schedules a writeback via the OS. Note: Windows is only partially async (sync to page cache, not to disk).