Enum piston::Event

source ·
pub enum Event {
    Input(Input, Option<u32>),
    Loop(Loop),
    Custom(EventId, Arc<dyn Any + Send + Sync>, Option<u32>),
}
Expand description

Models all events.

Variants§

§

Input(Input, Option<u32>)

Input events.

Time stamp is ignored when comparing input events for equality and order.

§

Loop(Loop)

Events that commonly used by event loops.

§

Custom(EventId, Arc<dyn Any + Send + Sync>, Option<u32>)

Custom event.

When comparing two custom events for equality, they always return false.

When comparing partial order of two custom events, the event ids are checked and if they are equal it returns None.

Time stamp is ignored both when comparing custom events for equality and order.

Trait Implementations§

source§

impl AfterRenderEvent for Event

source§

fn from_after_render_args( args: &AfterRenderArgs, _old_event: &Event ) -> Option<Event>

Creates an after render event.
source§

fn after_render<U, F>(&self, f: F) -> Option<U>where F: FnMut(&AfterRenderArgs) -> U,

Calls closure if this is an after render event.
source§

fn after_render_args(&self) -> Option<AfterRenderArgs>

Returns after render arguments.
source§

impl ButtonEvent for Event

source§

fn from_button_args(args: ButtonArgs, old_event: &Event) -> Option<Event>

Creates a button event. Read more
source§

fn button<U, F>(&self, f: F) -> Option<U>where F: FnMut(ButtonArgs) -> U,

Calls closure if this is a button event.
source§

fn button_args(&self) -> Option<ButtonArgs>

Returns button arguments.
source§

impl Clone for Event

source§

fn clone(&self) -> Event

Returns a copy 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 CloseEvent for Event

source§

fn from_close_args(args: &CloseArgs, old_event: &Event) -> Option<Event>

Creates a close event from arguments. Read more
source§

fn close<U, F>(&self, f: F) -> Option<U>where F: FnMut(&CloseArgs) -> U,

Calls closure if this is a close event.
source§

fn close_args(&self) -> Option<CloseArgs>

Returns close arguments.
source§

impl ControllerAxisEvent for Event

source§

fn from_controller_axis_args( args: ControllerAxisArgs, old_event: &Event ) -> Option<Event>

Creates a controller axis event. Read more
source§

fn controller_axis<U, F>(&self, f: F) -> Option<U>where F: FnMut(ControllerAxisArgs) -> U,

Calls closure if this is a controller axis event.
source§

fn controller_axis_args(&self) -> Option<ControllerAxisArgs>

Returns controller axis arguments.
source§

impl CursorEvent for Event

source§

fn from_cursor(cursor: bool, old_event: &Event) -> Option<Event>

Creates a cursor event. Read more
source§

fn cursor<U, F>(&self, f: F) -> Option<U>where F: FnMut(bool) -> U,

Calls closure if this is a cursor event.
source§

fn cursor_args(&self) -> Option<bool>

Returns cursor arguments.
source§

impl Debug for Event

source§

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

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

impl FocusEvent for Event

source§

fn from_focused(focused: bool, old_event: &Event) -> Option<Event>

Creates a focus event. Read more
source§

fn focus<U, F>(&self, f: F) -> Option<U>where F: FnMut(bool) -> U,

Calls closure if this is a focus event.
source§

fn focus_args(&self) -> Option<bool>

Returns focus arguments.
source§

impl<T> From<(T, Option<u32>)> for Eventwhere Input: From<T>,

source§

fn from(args: (T, Option<u32>)) -> Event

Converts to this type from the input type.
source§

impl From<AfterRenderArgs> for Event

source§

fn from(args: AfterRenderArgs) -> Event

Converts to this type from the input type.
source§

impl From<IdleArgs> for Event

source§

fn from(args: IdleArgs) -> Event

Converts to this type from the input type.
source§

impl From<Loop> for Event

source§

fn from(l: Loop) -> Event

Converts to this type from the input type.
source§

impl From<RenderArgs> for Event

source§

fn from(args: RenderArgs) -> Event

Converts to this type from the input type.
source§

impl<T> From<T> for Eventwhere Input: From<T>,

source§

fn from(args: T) -> Event

Converts to this type from the input type.
source§

impl From<UpdateArgs> for Event

source§

fn from(args: UpdateArgs) -> Event

Converts to this type from the input type.
source§

impl GenericEvent for Event

source§

fn event_id(&self) -> EventId

The id of this event.
source§

fn with_args<F, U>(&self, f: F) -> Uwhere F: FnMut(&(dyn Any + 'static)) -> U,

Calls closure with arguments
source§

fn time_stamp(&self) -> Option<u32>

Gets the time stamp of this event. Read more
source§

impl IdleEvent for Event

source§

fn from_idle_args(args: &IdleArgs, _old_event: &Event) -> Option<Event>

Creates an idle event.
source§

fn idle<U, F>(&self, f: F) -> Option<U>where F: FnMut(&IdleArgs) -> U,

Calls closure if this is an idle event.
source§

fn from_dt(dt: f64, old_event: &Self) -> Option<Self>

Creates an update event with delta time.
source§

fn idle_args(&self) -> Option<IdleArgs>

Returns idle arguments.
source§

impl MouseCursorEvent for Event

source§

fn from_pos(pos: [f64; 2], old_event: &Event) -> Option<Event>

Creates a mouse cursor event. Read more
source§

fn mouse_cursor<U, F>(&self, f: F) -> Option<U>where F: FnMut([f64; 2]) -> U,

Calls closure if this is a mouse cursor event.
source§

fn mouse_cursor_args(&self) -> Option<[f64; 2]>

Returns mouse cursor arguments.
source§

impl MouseRelativeEvent for Event

source§

fn from_pos(pos: [f64; 2], old_event: &Event) -> Option<Event>

Creates a mouse relative event. Read more
source§

fn mouse_relative<U, F>(&self, f: F) -> Option<U>where F: FnMut([f64; 2]) -> U,

Calls closure if this is a mouse relative event.
source§

fn mouse_relative_args(&self) -> Option<[f64; 2]>

Returns mouse relative arguments.
source§

impl MouseScrollEvent for Event

source§

fn from_pos(pos: [f64; 2], old_event: &Event) -> Option<Event>

Creates a mouse scroll event. Read more
source§

fn mouse_scroll<U, F>(&self, f: F) -> Option<U>where F: FnMut([f64; 2]) -> U,

Calls a closure if this is a mouse scroll event.
source§

fn mouse_scroll_args(&self) -> Option<[f64; 2]>

Returns mouse scroll arguments.
source§

impl PartialEq for Event

source§

fn eq(&self, other: &Event) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Event

source§

fn partial_cmp(&self, other: &Event) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl RenderEvent for Event

source§

fn from_render_args(args: &RenderArgs, _old_event: &Event) -> Option<Event>

Creates a render event.
source§

fn render<U, F>(&self, f: F) -> Option<U>where F: FnMut(&RenderArgs) -> U,

Calls closure if this is a render event.
source§

fn render_args(&self) -> Option<RenderArgs>

Returns render arguments.
source§

impl ResizeEvent for Event

source§

fn from_resize_args(args: &ResizeArgs, old_event: &Event) -> Option<Event>

Creates a resize event. Read more
source§

fn resize<U, F>(&self, f: F) -> Option<U>where F: FnMut(&ResizeArgs) -> U,

Calls closure if this is a resize event.
source§

fn resize_args(&self) -> Option<ResizeArgs>

Returns resize arguments.
source§

impl TextEvent for Event

source§

fn from_text(text: &str, old_event: &Event) -> Option<Event>

Creates a text event. Read more
source§

fn text<U, F>(&self, f: F) -> Option<U>where F: FnMut(&str) -> U,

Calls closure if this is a text event.
source§

fn text_args(&self) -> Option<String>

Returns text arguments.
source§

impl TouchEvent for Event

source§

fn from_touch_args(args: &TouchArgs, old_event: &Event) -> Option<Event>

Creates a touch event. Read more
source§

fn touch<U, F>(&self, f: F) -> Option<U>where F: FnMut(&TouchArgs) -> U,

Calls closure if this is a touch event.
source§

fn touch_args(&self) -> Option<TouchArgs>

Returns touch arguments.
source§

impl UpdateEvent for Event

source§

fn from_update_args(args: &UpdateArgs, _old_event: &Event) -> Option<Event>

Creates an update event.
source§

fn update<U, F>(&self, f: F) -> Option<U>where F: FnMut(&UpdateArgs) -> U,

Calls closure if this is an update event.
source§

fn from_dt(dt: f64, old_event: &Self) -> Option<Self>

Creates an update event with delta time.
source§

fn update_args(&self) -> Option<UpdateArgs>

Returns update arguments.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl !UnwindSafe for Event

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> PressEvent for Twhere T: ButtonEvent,

source§

fn from_button(button: Button, old_event: &T) -> Option<T>

Creates a press event. Read more
source§

fn press<U, F>(&self, f: F) -> Option<U>where F: FnMut(Button) -> U,

Calls closure if this is a press event.
source§

fn press_args(&self) -> Option<Button>

Returns press arguments.
source§

impl<T> ReleaseEvent for Twhere T: ButtonEvent,

source§

fn from_button(button: Button, old_event: &T) -> Option<T>

Creates a release event. Read more
source§

fn release<U, F>(&self, f: F) -> Option<U>where F: FnMut(Button) -> U,

Calls closure if this is a release event.
source§

fn release_args(&self) -> Option<Button>

Returns release arguments.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.