pub struct DynamicConfig<T, M = RW> { /* private fields */ }Expand description
A struct that contains a piece of configuration that can change.
Implementations§
Source§impl<T> DynamicConfig<T, RW>
impl<T> DynamicConfig<T, RW>
Source§impl<T, M> DynamicConfig<T, M>where
M: Mode,
impl<T, M> DynamicConfig<T, M>where
M: Mode,
Sourcepub fn get(&self) -> Twhere
T: Clone,
pub fn get(&self) -> Twhere
T: Clone,
Returns the current value.
Note: the returned value is not dynamic.
Sourcepub fn view_diff<U>(
self: &Arc<Self>,
to: impl Fn(&T) -> U + IsGlobal,
) -> Arc<DynamicConfig<U, RO>>
pub fn view_diff<U>( self: &Arc<Self>, to: impl Fn(&T) -> U + IsGlobal, ) -> Arc<DynamicConfig<U, RO>>
Returns a derived mode::RO dynamic configuration.
The derived configuration is updated only if the value actually changes.
Sourcepub fn view<U>(
self: &Arc<Self>,
to: impl Fn(&T) -> U + IsGlobal,
) -> Arc<DynamicConfig<U, RO>>
pub fn view<U>( self: &Arc<Self>, to: impl Fn(&T) -> U + IsGlobal, ) -> Arc<DynamicConfig<U, RO>>
Returns a derived mode::RO dynamic configuration.
Use view_diff() so the derived config doesn’t notify unless the value actually changes.
pub fn zip<T2, M2>( self: &Arc<Self>, right: &Arc<DynamicConfig<T2, M2>>, ) -> Arc<DynamicConfig<(T, T2), RO>>
Source§impl<T> DynamicConfig<T, RW>
impl<T> DynamicConfig<T, RW>
Sourcepub fn set(&self, make_new_config: impl FnOnce(&T) -> T)where
T: Clone,
pub fn set(&self, make_new_config: impl FnOnce(&T) -> T)where
T: Clone,
Modifies the current configuration.
This will trigger all handlers registered with add_notify(), such as views or derived configurations.
Sourcepub fn try_set<E>(
&self,
make_new_config: impl FnOnce(&T) -> Result<T, E>,
) -> Result<(), E>where
T: Clone,
pub fn try_set<E>(
&self,
make_new_config: impl FnOnce(&T) -> Result<T, E>,
) -> Result<(), E>where
T: Clone,
Modifies the current configuration.
Same as set() but accepts a mutation that could return an error.
Sourcepub fn silent_set(&self, make_new_config: impl FnOnce(&T) -> T)where
T: Clone,
pub fn silent_set(&self, make_new_config: impl FnOnce(&T) -> T)where
T: Clone,
Modifies the current configuration.
Same as set() but will not trigger notify.
Sourcepub fn silent_try_set<E>(
&self,
make_new_config: impl FnOnce(&T) -> Result<T, E>,
) -> Result<(), E>where
T: Clone,
pub fn silent_try_set<E>(
&self,
make_new_config: impl FnOnce(&T) -> Result<T, E>,
) -> Result<(), E>where
T: Clone,
Modifies the current configuration.
Does not trigger notify and accepts a mutation that could return an error.
Trait Implementations§
Source§impl<T: Default, M: Default> Default for DynamicConfig<T, M>
impl<T: Default, M: Default> Default for DynamicConfig<T, M>
Source§fn default() -> DynamicConfig<T, M>
fn default() -> DynamicConfig<T, M>
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for DynamicConfig<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for DynamicConfig<T>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<T> From<T> for DynamicConfig<T, RW>
impl<T> From<T> for DynamicConfig<T, RW>
Auto Trait Implementations§
impl<T, M = RW> !Freeze for DynamicConfig<T, M>
impl<T, M> RefUnwindSafe for DynamicConfig<T, M>where
M: RefUnwindSafe,
impl<T, M> Send for DynamicConfig<T, M>
impl<T, M> Sync for DynamicConfig<T, M>
impl<T, M> Unpin for DynamicConfig<T, M>
impl<T, M> UnwindSafe for DynamicConfig<T, M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request