pub struct Refreshable<T> { /* private fields */ }Expand description
A wrapper that auto-refreshes its value when configuration changes. 在配置更改时自动刷新其值的包装器。
Equivalent to Spring Cloud’s @RefreshScope bean behavior.
等价于 Spring Cloud 的 @RefreshScope bean 行为。
§Example / 示例
ⓘ
use hiver_config::refresh::Refreshable;
let mut port = Refreshable::new("server.port", 8080);
assert_eq!(*port.get(), 8080);
port.update("9090".to_string());
assert_eq!(*port.get(), 9090);Implementations§
Source§impl<T: Clone> Refreshable<T>
impl<T: Clone> Refreshable<T>
Sourcepub fn get(&self) -> RwLockReadGuard<'_, T>
pub fn get(&self) -> RwLockReadGuard<'_, T>
Get the current value / 获取当前值
Trait Implementations§
Source§impl<T: Clone> Clone for Refreshable<T>
impl<T: Clone> Clone for Refreshable<T>
Auto Trait Implementations§
impl<T> Freeze for Refreshable<T>
impl<T> RefUnwindSafe for Refreshable<T>
impl<T> Send for Refreshable<T>
impl<T> Sync for Refreshable<T>
impl<T> Unpin for Refreshable<T>
impl<T> UnsafeUnpin for Refreshable<T>
impl<T> UnwindSafe for Refreshable<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