#[repr(transparent)]pub struct State<Q = bool>(pub Q)
where
Q: ?Sized;
Expand description
State is a generalized state implementation, representing the state of a system or object.
Tuple Fields§
§0: Q
Implementations§
Source§impl<Q> State<Q>where
Q: RawState,
impl<Q> State<Q>where
Q: RawState,
Sourcepub fn create<F>(f: F) -> State<Q>where
F: FnOnce() -> Q,
pub fn create<F>(f: F) -> State<Q>where
F: FnOnce() -> Q,
generate a new state by invoking the given function and capturing its output.
Sourcepub const fn as_ptr(&self) -> *const Q
pub const fn as_ptr(&self) -> *const Q
returns a new instance of state with a raw pointer to the inner value.
Sourcepub const fn as_mut_ptr(&mut self) -> *mut Q
pub const fn as_mut_ptr(&mut self) -> *mut Q
returns a new instance of state with a mutable raw pointer to the inner value.
Sourcepub const fn get_mut(&mut self) -> &mut Q
pub const fn get_mut(&mut self) -> &mut Q
returns a mutable reference to the inner value of the state.
Sourcepub fn map<R, F>(self, f: F) -> State<R>where
F: FnOnce(Q) -> R,
pub fn map<R, F>(self, f: F) -> State<R>where
F: FnOnce(Q) -> R,
State::map applies the given function onto the inner value of the state, returning a new state with the result.
Sourcepub const fn replace(&mut self, state: Q) -> Q
pub const fn replace(&mut self, state: Q) -> Q
replace
the inner value of the state with the given state,
Sourcepub fn reset(&mut self) -> &mut State<Q>where
Q: Default,
pub fn reset(&mut self) -> &mut State<Q>where
Q: Default,
Clears the state, setting it to its default value.
Sourcepub const fn swap(&mut self, other: &mut State<Q>)
pub const fn swap(&mut self, other: &mut State<Q>)
swap
the inner value of the state with that of the given state.
Sourcepub fn take(&mut self) -> Qwhere
Q: Default,
pub fn take(&mut self) -> Qwhere
Q: Default,
take
the inner value of the state, leaving the logical default in
its place
Sourcepub fn as_halt(&self) -> State<Halt<&Q>>
pub fn as_halt(&self) -> State<Halt<&Q>>
converts the current reference into a haltable state initialized with the current state
Sourcepub fn into_halt(self) -> State<Halt<Q>>
pub fn into_halt(self) -> State<Halt<Q>>
consumes the wrapper to create another, haltable state that is initialized with the current state
Sourcepub fn halt(self) -> State<Halt<Q>>
pub fn halt(self) -> State<Halt<Q>>
consumes the current state, returning a new one with a Halt
variant initialized with the current value.
Sourcepub fn as_any(&self) -> State<Box<dyn Any>>where
Q: Clone + 'static,
pub fn as_any(&self) -> State<Box<dyn Any>>where
Q: Clone + 'static,
Converts the inner type into a boxed “any” state, returning a new instance of state
Sourcepub fn into_any(self) -> State<Box<dyn Any>>where
Q: 'static,
pub fn into_any(self) -> State<Box<dyn Any>>where
Q: 'static,
Converts the inner type into a boxed “any” state, returning a new instance of state
Wraps the inner value of the state with an [Arc
] and returns a new instance of State
returns a shared reference to the state.
Sourcepub const fn view_mut(&mut self) -> State<&mut Q>
pub const fn view_mut(&mut self) -> State<&mut Q>
returns a state with a mutable reference to the inner value.
Sourcepub fn get_inner_type_name(&self) -> &'static str
pub fn get_inner_type_name(&self) -> &'static str
returns the name
of the generic inner type, Q
.
Sourcepub fn get_inner_type_id(&self) -> TypeIdwhere
Q: 'static,
pub fn get_inner_type_id(&self) -> TypeIdwhere
Q: 'static,
returns the type id
of the generic inner type, Q
.
Source§impl<Q> State<*mut Q>where
Q: RawState,
impl<Q> State<*mut Q>where
Q: RawState,
Sourcepub fn from_mut_ptr(ptr: *mut Q) -> State<*mut Q>
pub fn from_mut_ptr(ptr: *mut Q) -> State<*mut Q>
Creates a new instance of state with a mutable raw pointer to the inner value.
Source§impl<Q> State<MaybeUninit<Q>>where
Q: RawState,
impl<Q> State<MaybeUninit<Q>>where
Q: RawState,
Sourcepub fn init(value: Q) -> State<MaybeUninit<Q>>
pub fn init(value: Q) -> State<MaybeUninit<Q>>
Creates a new instance of state with an initialized inner value.
Sourcepub const fn uninit() -> State<MaybeUninit<Q>>
pub const fn uninit() -> State<MaybeUninit<Q>>
Creates a new instance of state with an uninitialized inner value.
Sourcepub unsafe fn assume_init(self) -> State<Q>
pub unsafe fn assume_init(self) -> State<Q>
Source§impl State
impl State
Sourcepub const fn from_false() -> State
pub const fn from_false() -> State
returns a new instance of State
with an inner state of false
.
Source§impl State<Box<dyn Any>>
impl State<Box<dyn Any>>
Sourcepub fn downcast<Q>(self) -> Result<State<Box<Q>>, StateError>where
Q: Any,
pub fn downcast<Q>(self) -> Result<State<Box<Q>>, StateError>where
Q: Any,
Attempts to downcast the state to a concrete type Q
; returns an error if the state
is not of type Q
.
Trait Implementations§
Source§impl<_A, _B> AddAssign<State<_B>> for State<_A>where
_A: AddAssign<_B>,
impl<_A, _B> AddAssign<State<_B>> for State<_A>where
_A: AddAssign<_B>,
Source§fn add_assign(&mut self, rhs: State<_B>)
fn add_assign(&mut self, rhs: State<_B>)
+=
operation. Read moreSource§impl<_A, _B> BitAndAssign<State<_B>> for State<_A>where
_A: BitAndAssign<_B>,
impl<_A, _B> BitAndAssign<State<_B>> for State<_A>where
_A: BitAndAssign<_B>,
Source§fn bitand_assign(&mut self, rhs: State<_B>)
fn bitand_assign(&mut self, rhs: State<_B>)
&=
operation. Read moreSource§impl<_A, _B> BitOrAssign<State<_B>> for State<_A>where
_A: BitOrAssign<_B>,
impl<_A, _B> BitOrAssign<State<_B>> for State<_A>where
_A: BitOrAssign<_B>,
Source§fn bitor_assign(&mut self, rhs: State<_B>)
fn bitor_assign(&mut self, rhs: State<_B>)
|=
operation. Read moreSource§impl<_A, _B> BitXorAssign<State<_B>> for State<_A>where
_A: BitXorAssign<_B>,
impl<_A, _B> BitXorAssign<State<_B>> for State<_A>where
_A: BitXorAssign<_B>,
Source§fn bitxor_assign(&mut self, rhs: State<_B>)
fn bitxor_assign(&mut self, rhs: State<_B>)
^=
operation. Read moreSource§impl<Q> BorrowMut<Q> for State<Q>
impl<Q> BorrowMut<Q> for State<Q>
Source§fn borrow_mut(&mut self) -> &mut Q
fn borrow_mut(&mut self) -> &mut Q
Source§impl<'de, Q> Deserialize<'de> for State<Q>where
Q: Deserialize<'de> + ?Sized,
impl<'de, Q> Deserialize<'de> for State<Q>where
Q: Deserialize<'de> + ?Sized,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<State<Q>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<State<Q>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<_A, _B> DivAssign<State<_B>> for State<_A>where
_A: DivAssign<_B>,
impl<_A, _B> DivAssign<State<_B>> for State<_A>where
_A: DivAssign<_B>,
Source§fn div_assign(&mut self, rhs: State<_B>)
fn div_assign(&mut self, rhs: State<_B>)
/=
operation. Read moreSource§impl<_A, _B> MulAssign<State<_B>> for State<_A>where
_A: MulAssign<_B>,
impl<_A, _B> MulAssign<State<_B>> for State<_A>where
_A: MulAssign<_B>,
Source§fn mul_assign(&mut self, rhs: State<_B>)
fn mul_assign(&mut self, rhs: State<_B>)
*=
operation. Read moreSource§impl<Q> Num for State<Q>
impl<Q> Num for State<Q>
type FromStrRadixErr = <Q as Num>::FromStrRadixErr
Source§impl<Q> Ord for State<Q>
impl<Q> Ord for State<Q>
Source§impl<'a, Q> PartialOrd<&'a Q> for State<Q>where
Q: PartialOrd,
impl<'a, Q> PartialOrd<&'a Q> for State<Q>where
Q: PartialOrd,
Source§impl<'a, Q> PartialOrd<&'a mut Q> for State<Q>where
Q: PartialOrd,
impl<'a, Q> PartialOrd<&'a mut Q> for State<Q>where
Q: PartialOrd,
Source§impl<Q> PartialOrd<Q> for State<Q>where
Q: PartialOrd,
impl<Q> PartialOrd<Q> for State<Q>where
Q: PartialOrd,
Source§impl<Q> PartialOrd for State<Q>where
Q: PartialOrd + ?Sized,
impl<Q> PartialOrd for State<Q>where
Q: PartialOrd + ?Sized,
Source§impl<_A, _B> RemAssign<State<_B>> for State<_A>where
_A: RemAssign<_B>,
impl<_A, _B> RemAssign<State<_B>> for State<_A>where
_A: RemAssign<_B>,
Source§fn rem_assign(&mut self, rhs: State<_B>)
fn rem_assign(&mut self, rhs: State<_B>)
%=
operation. Read moreSource§impl<Q> Serialize for State<Q>
impl<Q> Serialize for State<Q>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl<_A, _B> ShlAssign<State<_B>> for State<_A>where
_A: ShlAssign<_B>,
impl<_A, _B> ShlAssign<State<_B>> for State<_A>where
_A: ShlAssign<_B>,
Source§fn shl_assign(&mut self, rhs: State<_B>)
fn shl_assign(&mut self, rhs: State<_B>)
<<=
operation. Read moreSource§impl<_A, _B> ShrAssign<State<_B>> for State<_A>where
_A: ShrAssign<_B>,
impl<_A, _B> ShrAssign<State<_B>> for State<_A>where
_A: ShrAssign<_B>,
Source§fn shr_assign(&mut self, rhs: State<_B>)
fn shr_assign(&mut self, rhs: State<_B>)
>>=
operation. Read moreSource§impl<Q> Stated for State<Q>where
Q: RawState,
impl<Q> Stated for State<Q>where
Q: RawState,
Source§fn into_inner(self) -> Q
fn into_inner(self) -> Q
Source§fn set(&mut self, inner: Self::Item) -> &mut Self
fn set(&mut self, inner: Self::Item) -> &mut Self
Source§impl<_A, _B> SubAssign<State<_B>> for State<_A>where
_A: SubAssign<_B>,
impl<_A, _B> SubAssign<State<_B>> for State<_A>where
_A: SubAssign<_B>,
Source§fn sub_assign(&mut self, rhs: State<_B>)
fn sub_assign(&mut self, rhs: State<_B>)
-=
operation. Read more