Enum esp32_simple::infra::State

source ·
pub enum State<T = ()> {
    Off,
    On(Option<T>),
}
Expand description

Represents an on/off state, optionally carrying additional data when on.

§Type Parameters

  • T - The type of additional data carried when in the On state. Defaults to ().

§Variants

  • Off - The switch is turned off.
  • On(Option<T>) - The switch is on, optionally with additional data.

Variants§

§

Off

§

On(Option<T>)

Implementations§

source§

impl<T> State<T>

source

pub const fn on() -> Self

Creates a new State in the On position with no additional data.

§Returns

A State in the On position with None data.

source

pub const fn off() -> Self

Creates a new State in the Off position.

§Returns

A State in the Off position.

source

pub fn is_off(&self) -> bool

Returns true if the state is Off.

§Returns

true if Off, false otherwise.

source

pub fn is_on(&self) -> bool

Returns true if the state is On.

§Returns

true if On, false otherwise.

source

pub fn toggle(&mut self)

Toggles between On and Off, clearing any additional data.

Auto Trait Implementations§

§

impl<T> Freeze for State<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for State<T>
where T: RefUnwindSafe,

§

impl<T> Send for State<T>
where T: Send,

§

impl<T> Sync for State<T>
where T: Sync,

§

impl<T> Unpin for State<T>
where T: Unpin,

§

impl<T> UnwindSafe for State<T>
where T: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.