OptimizedEvent

Enum OptimizedEvent 

Source
pub enum OptimizedEvent<M> {
    Key(KeyEvent),
    Mouse(MouseEvent),
    Resize {
        width: u16,
        height: u16,
    },
    Tick,
    User(InlineMessage<M>),
    Quit,
    Focus,
    Blur,
    Suspend,
    Resume,
    Paste(Cow<'static, str>),
    // some variants omitted
}
Expand description

Zero-cost event wrapper with inline storage for small messages

Variants§

§

Key(KeyEvent)

A keyboard event - stored inline, no allocation

§

Mouse(MouseEvent)

A mouse event - stored inline, no allocation

§

Resize

Terminal was resized - stored inline, no allocation

Fields

§width: u16

Terminal width in columns

§height: u16

Terminal height in rows

§

Tick

A tick event - stored inline, no allocation

§

User(InlineMessage<M>)

User-defined message with inline storage optimization

§

Quit

Request to quit the program - stored inline, no allocation

§

Focus

Terminal gained focus - stored inline, no allocation

§

Blur

Terminal lost focus - stored inline, no allocation

§

Suspend

Program suspend request (Ctrl+Z) - stored inline, no allocation

§

Resume

Program resumed from suspend - stored inline, no allocation

§

Paste(Cow<'static, str>)

Bracketed paste event with COW string for efficiency

Implementations§

Source§

impl<M> OptimizedEvent<M>

Source

pub fn user(msg: M) -> Self

Create a new user event with automatic storage optimization

Source

pub const fn is_key(&self) -> bool

Check if this is a key event

Source

pub fn is_key_press(&self, key: Key) -> bool

Check if this is a specific key press

Source

pub const fn as_key(&self) -> Option<&KeyEvent>

Get the key event if this is a key event

Source

pub const fn is_mouse(&self) -> bool

Check if this is a mouse event

Source

pub const fn as_mouse(&self) -> Option<&MouseEvent>

Get the mouse event if this is a mouse event

Source

pub const fn is_user(&self) -> bool

Check if this is a user message

Source

pub fn as_user(&self) -> Option<&M>

Get the user message if this is a user event

Source

pub fn into_user(self) -> Option<M>

Take the user message if this is a user event

Source

pub const fn is_quit(&self) -> bool

Check if this is a quit event

Source

pub const fn is_tick(&self) -> bool

Check if this is a tick event

Source

pub const fn is_resize(&self) -> bool

Check if this is a resize event

Source

pub const fn as_resize(&self) -> Option<(u16, u16)>

Get resize dimensions if this is a resize event

Trait Implementations§

Source§

impl<M: Clone> Clone for OptimizedEvent<M>

Source§

fn clone(&self) -> OptimizedEvent<M>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<M: Debug> Debug for OptimizedEvent<M>

Source§

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

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

impl<M> From<Event<M>> for OptimizedEvent<M>

Convert from the standard Event to OptimizedEvent

Source§

fn from(event: Event<M>) -> Self

Converts to this type from the input type.
Source§

impl<M> From<OptimizedEvent<M>> for Event<M>

Convert from OptimizedEvent back to standard Event

Source§

fn from(event: OptimizedEvent<M>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<M> Freeze for OptimizedEvent<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for OptimizedEvent<M>
where M: RefUnwindSafe,

§

impl<M> Send for OptimizedEvent<M>
where M: Send,

§

impl<M> Sync for OptimizedEvent<M>
where M: Sync,

§

impl<M> Unpin for OptimizedEvent<M>
where M: Unpin,

§

impl<M> UnwindSafe for OptimizedEvent<M>
where M: UnwindSafe,

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> Inspectable for T

Source§

fn inspect(self, label: &str) -> Self
where Self: Debug,

Inspect this value with a label
Source§

fn inspect_if(self, condition: bool, label: &str) -> Self
where Self: Debug,

Conditionally inspect this value
Source§

fn inspect_with<F>(self, label: &str, f: F) -> Self
where F: FnOnce(&Self) -> String,

Inspect with a custom formatter
Source§

fn tap<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Tap into the value for side effects
Source§

fn tap_if<F>(self, condition: bool, f: F) -> Self
where F: FnOnce(&Self),

Conditionally tap into the value
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.
Source§

impl<T> Message for T
where T: Send + 'static,