Skip to main content

Act

Struct Act 

Source
pub struct Act<'a> {
    pub label: &'a str,
    pub key: Option<&'a str>,
    pub tone: Tone,
    pub state: Option<State>,
}
Expand description

Something the user can do, and what it costs to say so.

Added 0.17.0, out of quasi-tui: the terminal renderer had drawn one of these for months and every other consumer that wanted a button had written its own, because this layer named RowPart::Actions as a slot and never named the thing that goes in it. Beside Meter and Figure for the reason those are here: a renderer that is handed the parts has to decide how to say them, and a renderer that is handed a finished string has already had the decision made for it.

No address. Where a control goes is the app’s business and every host follows it differently — an hx-get, a protocol URL, a function call — so the description says what the control is and the caller keeps what it does. That is the same split Choice makes.

No confirmation flag either, and that one is a finding rather than an omission: a question asked after a control is pressed belongs to whatever is holding the interaction, and a renderer that drew it would be asking before there was anything to answer.

Fields§

§label: &'a str

What the control says.

§key: Option<&'a str>

The key that reaches it where a host has keys.

The one member written for a terminal before there was one. A webview hangs it off accesskey or ignores it; a terminal has nothing else to offer, so this is the whole of how a control is reached there.

§tone: Tone

What pressing it means. Tone::Danger is the destructive one.

§state: Option<State>

Focus, disabled, or neither.

State::Disabled is the one that changes what a renderer may do: see State::suppresses_interaction, which is what says a disabled control is drawn and not reachable.

Implementations§

Source§

impl<'a> Act<'a>

Source

pub const fn new(label: &'a str) -> Self

An ordinary control, reachable, with no key.

Source

pub const fn key(self, key: &'a str) -> Self

The key that reaches it.

Source

pub const fn tone(self, tone: Tone) -> Self

What pressing it means.

Source

pub const fn state(self, state: State) -> Self

Focus, or disabled.

Source

pub fn disabled(&self) -> bool

Whether the control is drawn and does not answer.

Trait Implementations§

Source§

impl<'a> Clone for Act<'a>

Source§

fn clone(&self) -> Act<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Act<'a>

Source§

impl<'a> Debug for Act<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for Act<'a>

Source§

impl<'a> Hash for Act<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for Act<'a>

Source§

fn eq(&self, other: &Act<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Act<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Act<'a>

§

impl<'a> RefUnwindSafe for Act<'a>

§

impl<'a> Send for Act<'a>

§

impl<'a> Sync for Act<'a>

§

impl<'a> Unpin for Act<'a>

§

impl<'a> UnsafeUnpin for Act<'a>

§

impl<'a> UnwindSafe for Act<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.