pub struct State<T: Send + Sync + 'static> { /* private fields */ }Expand description
响应式状态持有者。 支持原子读写、变更通知、算术运算等。
Implementations§
Source§impl<T: Send + Sync + 'static> State<T>
impl<T: Send + Sync + 'static> State<T>
Sourcepub fn try_write(&self) -> Option<StateMutRef<'_, T>>
pub fn try_write(&self) -> Option<StateMutRef<'_, T>>
尝试获取可变引用,支持变更通知,失败时返回 None。
Sourcepub fn write(&self) -> StateMutRef<'_, T>
pub fn write(&self) -> StateMutRef<'_, T>
获取可变引用,支持变更通知,失败时 panic。
Sourcepub fn try_write_no_update(&self) -> Option<StateMutNoUpdate<'_, T>>
pub fn try_write_no_update(&self) -> Option<StateMutNoUpdate<'_, T>>
尝试获取可变引用,不触发变更通知,失败时返回 None。
Sourcepub fn write_no_update(&self) -> StateMutNoUpdate<'_, T>
pub fn write_no_update(&self) -> StateMutNoUpdate<'_, T>
获取可变引用,不触发变更通知,失败时 panic。
Sourcepub fn set_no_update(&mut self, value: T)
pub fn set_no_update(&mut self, value: T)
设置状态值,不触发变更通知。
Trait Implementations§
Source§impl<T: AddAssign<T> + Copy + Sync + Send + 'static> AddAssign<T> for State<T>
impl<T: AddAssign<T> + Copy + Sync + Send + 'static> AddAssign<T> for State<T>
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the
+= operation. Read moreSource§impl<T: DivAssign<T> + Copy + Sync + Send + 'static> DivAssign<T> for State<T>
impl<T: DivAssign<T> + Copy + Sync + Send + 'static> DivAssign<T> for State<T>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/= operation. Read moreSource§impl<T: MulAssign<T> + Copy + Sync + Send + 'static> MulAssign<T> for State<T>
impl<T: MulAssign<T> + Copy + Sync + Send + 'static> MulAssign<T> for State<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*= operation. Read moreSource§impl<T: PartialOrd<T> + Sync + Send + 'static> PartialOrd<T> for State<T>
impl<T: PartialOrd<T> + Sync + Send + 'static> PartialOrd<T> for State<T>
Source§impl<T: PartialOrd<T> + Sync + Send + 'static> PartialOrd for State<T>
impl<T: PartialOrd<T> + Sync + Send + 'static> PartialOrd for State<T>
Source§impl<T: SubAssign<T> + Copy + Sync + Send + 'static> SubAssign<T> for State<T>
impl<T: SubAssign<T> + Copy + Sync + Send + 'static> SubAssign<T> for State<T>
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
Performs the
-= operation. Read moreimpl<T: Send + Sync + 'static> Copy for State<T>
impl<T: Eq + Sync + Send + 'static> Eq for State<T>
Auto Trait Implementations§
impl<T> Freeze for State<T>
impl<T> !RefUnwindSafe for State<T>
impl<T> Send for State<T>
impl<T> Sync for State<T>
impl<T> Unpin for State<T>where
T: Unpin,
impl<T> !UnwindSafe for State<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more