pub struct ConfigHandle<T: Send + Sync + 'static> { /* private fields */ }Expand description
A shared handle to a configuration value.
ConfigHandle<T> wraps an Arc<ArcSwap<T>> to provide:
load(): Read the current configuration snapshot (returnsArc<T>).set(): Update the configuration value.clone: Share the same underlying swap cell across multiple handles.
Multiple ConfigHandle<T> clones point to the same underlying swap cell.
Updates via one handle are immediately visible to all other handles.
Old snapshots (returned by load()) remain valid after updates.
§Type Constraints
T must satisfy Send + Sync + 'static and Sized.
§Example
use trait_kit::core::config::ConfigHandle;
let handle = ConfigHandle::new(42);
assert_eq!(*handle.load(), 42);
let cloned = handle.clone();
handle.set(100);
assert_eq!(*cloned.load(), 100);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for ConfigHandle<T>
impl<T> RefUnwindSafe for ConfigHandle<T>where
T: RefUnwindSafe,
impl<T> Send for ConfigHandle<T>
impl<T> Sync for ConfigHandle<T>
impl<T> Unpin for ConfigHandle<T>
impl<T> UnsafeUnpin for ConfigHandle<T>
impl<T> UnwindSafe for ConfigHandle<T>where
T: RefUnwindSafe,
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