Enum yy_typings::object_yy::EventType [−][src]
pub enum EventType {
Show 14 variants
Create,
Destroy,
Cleanup,
Step(Stage),
Alarm(usize),
Draw(DrawEvent),
Collision,
Mouse(MouseEvent),
KeyDown(VirtualKeyCode),
KeyPress(VirtualKeyCode),
KeyRelease(VirtualKeyCode),
Gesture(GestureEvent),
Other(OtherEvent),
Async(AsyncEvent),
}
Expand description
Describes the current event type. Users can make most events freely, though
special care should be taken that Alarm
’s .0 field is less than
ALARM_MAX
, and the same for the OtherEvent
’s usize wrappers. To make
sure some event has been validly created, is_valid
has been provided.
Note: only serde_json serialization and deserialization is supported for
EventType. Yaml, and other text / WYSIWYG data formats should be fine, but
Bincode and other binary sequences are unlikely to succesfully serialize
this. This is due to our use of serde’s flatten
, which runs afoul of this issue: https://github.com/servo/bincode/issues/245
Variants
Step(Stage)
Tuple Fields of Step
0: Stage
Alarm(usize)
Tuple Fields of Alarm
0: usize
Draw(DrawEvent)
Tuple Fields of Draw
0: DrawEvent
Mouse(MouseEvent)
Tuple Fields of Mouse
0: MouseEvent
KeyDown(VirtualKeyCode)
Tuple Fields of KeyDown
KeyPress(VirtualKeyCode)
Tuple Fields of KeyPress
KeyRelease(VirtualKeyCode)
Tuple Fields of KeyRelease
Gesture(GestureEvent)
Tuple Fields of Gesture
0: GestureEvent
Other(OtherEvent)
Tuple Fields of Other
0: OtherEvent
Async(AsyncEvent)
Tuple Fields of Async
0: AsyncEvent
Implementations
Gets the filename for a given event with its requisite base. We return in this format to reduce allocating a string per call, as this filename will likely become allocated on some path in the future.
let (base_name, numeric_id) = EventType::Create;
assert_eq!(base_name, "Create_");
assert_eq!(numeric_id, 0);
Returns the filename like it will appear in a file.
pub fn parse_filename(
value: &str,
event_num: usize
) -> Result<EventType, EventTypeConvertErrors>
pub fn parse_filename(
value: &str,
event_num: usize
) -> Result<EventType, EventTypeConvertErrors>
Parses a given filename and number into an EventType
, if valid.
A simple way to parse a value. It does a split on the string, which
basically means it needs to follow the pattern Create_0
and
similar.
Trait Implementations
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
type Error = EventTypeConvertErrors
type Error = EventTypeConvertErrors
The type returned in the event of a conversion error.
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for EventType
impl UnwindSafe for EventType
Blanket Implementations
Mutably borrows from an owned value. Read more