pub trait State<T, ReplyParams>: Clone{
type Stream: Stream<Item = Reply<ReplyParams>>;
// Required methods
fn new(value: T) -> Self;
fn set(&mut self, value: T) -> impl Future<Output = ()> + Send;
fn get(&self) -> T;
fn stream(&self) -> Self::Stream;
fn stream_once(&self) -> Self::Stream;
}Expand description
Trait for a notified state that tracks a value and broadcasts changes.
This is useful for implementing service properties that notify subscribers when they change.
Required Associated Types§
Required Methods§
Sourcefn set(&mut self, value: T) -> impl Future<Output = ()> + Send
fn set(&mut self, value: T) -> impl Future<Output = ()> + Send
Set the value and notify all listeners.
Sourcefn stream_once(&self) -> Self::Stream
fn stream_once(&self) -> Self::Stream
Get a stream of replies for this state, that only yields one reply: the current state.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.