#[repr(transparent)]pub struct State<Q: ?Sized = bool>(pub Q);Expand description
State is a generalized state implementation, representing the state of a system or object.
Tuple Fields§
§0: QImplementations§
Source§impl<Q> State<*mut Q>
impl<Q> State<*mut Q>
Sourcepub fn from_mut_ptr(ptr: *mut Q) -> Self
pub fn from_mut_ptr(ptr: *mut Q) -> Self
Creates a new instance of state with a mutable raw pointer to the inner value.
Source§impl<Q> State<MaybeUninit<Q>>
impl<Q> State<MaybeUninit<Q>>
Sourcepub const fn uninit() -> Self
pub const fn uninit() -> Self
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>
Converts the state into a new instance of State with an initialized state.
Source§impl State<Box<dyn Any>>
impl State<Box<dyn Any>>
Sourcepub fn downcast<Q>(self) -> Result<State<Box<Q>>, Error>where
Q: Any,
pub fn downcast<Q>(self) -> Result<State<Box<Q>>, Error>where
Q: Any,
Attempts to downcast the state to a concrete type Q; returns an error if the state
is not of type Q.
Source§impl<Q> State<Option<Q>>
impl<Q> State<Option<Q>>
Sourcepub fn none() -> Self
pub fn none() -> Self
Creates a new instance of state whose inner state is Option::None.
Sourcepub fn some(value: Q) -> Self
pub fn some(value: Q) -> Self
Creates a new instance of state whose inner state is Option::Some.
Source§impl<Q> State<Q>
impl<Q> State<Q>
pub fn from_value(state: Q) -> Self
Sourcepub fn as_ptr(&self) -> *const Q
pub fn as_ptr(&self) -> *const Q
Returns a new instance of state with a raw pointer to the inner value.
Sourcepub fn as_mut_ptr(&mut self) -> *mut Q
pub fn as_mut_ptr(&mut self) -> *mut Q
Returns a new instance of state with a mutable raw pointer to the inner value.
Sourcepub fn get_mut(&mut self) -> &mut Q
pub fn get_mut(&mut self) -> &mut Q
Returns a mutable reference to the inner value of the state.
Sourcepub fn into_inner(self) -> Q
pub fn into_inner(self) -> Q
Consumes and returns 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 fn replace(&mut self, state: Q) -> Q
pub fn replace(&mut self, state: Q) -> Q
Replaces the state with a new value, returning the old value.
Sourcepub fn swap<S>(&mut self, other: &mut S)where
S: RawState<Q = Q>,
pub fn swap<S>(&mut self, other: &mut S)where
S: RawState<Q = Q>,
Swaps 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,
Takes the inner value of the state, replacing it with the default value and returning the previous value.
Sourcepub fn as_halt(&self) -> State<Halt<&Q>>
pub fn as_halt(&self) -> State<Halt<&Q>>
Returns a halted state with an immutable reference to the state.
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 fn to_mut(&mut self) -> State<&mut Q>
pub fn to_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.
Trait Implementations§
Source§impl<A, B> AddAssign<B> for State<A>where
A: AddAssign<B>,
impl<A, B> AddAssign<B> for State<A>where
A: AddAssign<B>,
Source§fn add_assign(&mut self, rhs: B)
fn add_assign(&mut self, rhs: B)
+= operation. Read moreSource§impl<A, B> BitAndAssign<B> for State<A>where
A: BitAndAssign<B>,
impl<A, B> BitAndAssign<B> for State<A>where
A: BitAndAssign<B>,
Source§fn bitand_assign(&mut self, rhs: B)
fn bitand_assign(&mut self, rhs: B)
&= operation. Read moreSource§impl<A, B> BitOrAssign<B> for State<A>where
A: BitOrAssign<B>,
impl<A, B> BitOrAssign<B> for State<A>where
A: BitOrAssign<B>,
Source§fn bitor_assign(&mut self, rhs: B)
fn bitor_assign(&mut self, rhs: B)
|= operation. Read moreSource§impl<A, B> BitXorAssign<B> for State<A>where
A: BitXorAssign<B>,
impl<A, B> BitXorAssign<B> for State<A>where
A: BitXorAssign<B>,
Source§fn bitxor_assign(&mut self, rhs: B)
fn bitxor_assign(&mut self, rhs: 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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<A, B> DivAssign<B> for State<A>where
A: DivAssign<B>,
impl<A, B> DivAssign<B> for State<A>where
A: DivAssign<B>,
Source§fn div_assign(&mut self, rhs: B)
fn div_assign(&mut self, rhs: B)
/= operation. Read moreSource§impl<A, B> MulAssign<B> for State<A>where
A: MulAssign<B>,
impl<A, B> MulAssign<B> for State<A>where
A: MulAssign<B>,
Source§fn mul_assign(&mut self, rhs: B)
fn mul_assign(&mut self, rhs: B)
*= operation. Read moreSource§impl<Q> Num for State<Q>where
Q: Num,
impl<Q> Num for State<Q>where
Q: Num,
type FromStrRadixErr = <Q as Num>::FromStrRadixErr
Source§fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36). Read moreSource§impl<Q: Ord + ?Sized> Ord for State<Q>
impl<Q: Ord + ?Sized> Ord for State<Q>
Source§impl<Q> PartialOrd<Q> for State<Q>where
Q: PartialOrd<Q>,
impl<Q> PartialOrd<Q> for State<Q>where
Q: PartialOrd<Q>,
Source§impl<Q: PartialOrd + ?Sized> PartialOrd for State<Q>
impl<Q: PartialOrd + ?Sized> PartialOrd for State<Q>
Source§impl<A, B> RemAssign<B> for State<A>where
A: RemAssign<B>,
impl<A, B> RemAssign<B> for State<A>where
A: RemAssign<B>,
Source§fn rem_assign(&mut self, rhs: B)
fn rem_assign(&mut self, rhs: B)
%= operation. Read moreSource§impl<A, B> ShlAssign<B> for State<A>where
A: ShlAssign<B>,
impl<A, B> ShlAssign<B> for State<A>where
A: ShlAssign<B>,
Source§fn shl_assign(&mut self, rhs: B)
fn shl_assign(&mut self, rhs: B)
<<= operation. Read moreSource§impl<A, B> ShrAssign<B> for State<A>where
A: ShrAssign<B>,
impl<A, B> ShrAssign<B> for State<A>where
A: ShrAssign<B>,
Source§fn shr_assign(&mut self, rhs: B)
fn shr_assign(&mut self, rhs: B)
>>= operation. Read moreSource§impl<A, B> SubAssign<B> for State<A>where
A: SubAssign<B>,
impl<A, B> SubAssign<B> for State<A>where
A: SubAssign<B>,
Source§fn sub_assign(&mut self, rhs: B)
fn sub_assign(&mut self, rhs: B)
-= operation. Read more