pub struct Source<S> { /* private fields */ }Expand description
State source, the initiator of state change.
Implementations§
Source§impl<S> Source<S>
impl<S> Source<S>
Sourcepub fn create(init_value: S, capacity: usize) -> Self
pub fn create(init_value: S, capacity: usize) -> Self
Create a state source with custom broadcast channel capacity.
- capacity: broadcast channel capacity
Sourcepub fn reader_ex<T>(&self, func: ConvertFunc<S, T>) -> ReaderEx<S, T>
pub fn reader_ex<T>(&self, func: ConvertFunc<S, T>) -> ReaderEx<S, T>
Get reader of state source, can be subscribed by responders.
Sourcepub async fn num_of_subs(&self) -> usize
pub async fn num_of_subs(&self) -> usize
Num of subscriptions.
Sourcepub async fn change(&self, s: S) -> Result<(), SourceChangeError>
pub async fn change(&self, s: S) -> Result<(), SourceChangeError>
Change state of source.
Sourcepub async fn wait_change(&self, s: S) -> Result<(), SourceChangeError>
pub async fn wait_change(&self, s: S) -> Result<(), SourceChangeError>
Change state of source, and wait responders to finish actions upon the change event.
Sourcepub async fn modify(
&self,
func: impl Fn(S) -> S + 'static,
) -> Result<(), SourceChangeError>
pub async fn modify( &self, func: impl Fn(S) -> S + 'static, ) -> Result<(), SourceChangeError>
Change state of source by modifying it with a func.
Sourcepub async fn wait_modify(
&self,
func: impl Fn(S) -> S + 'static,
) -> Result<(), SourceChangeError>
pub async fn wait_modify( &self, func: impl Fn(S) -> S + 'static, ) -> Result<(), SourceChangeError>
Change state of source by modifying it with a func, and wait responders to finish actions upon the change event.
Sourcepub async fn touch(&self) -> Result<(), SourceChangeError>
pub async fn touch(&self) -> Result<(), SourceChangeError>
Create a change event without changing state of source really.
Trait Implementations§
Auto Trait Implementations§
impl<S> !RefUnwindSafe for Source<S>
impl<S> !UnwindSafe for Source<S>
impl<S> Freeze for Source<S>
impl<S> Send for Source<S>
impl<S> Sync for Source<S>
impl<S> Unpin for Source<S>
impl<S> UnsafeUnpin for Source<S>
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