1use crate::*;
2
3impl std::fmt::Display for NativeEventName {
8 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 match self {
19 NativeEventName::Click => write!(f, "click"),
20 NativeEventName::DblClick => write!(f, "dblclick"),
21 NativeEventName::MouseDown => write!(f, "mousedown"),
22 NativeEventName::MouseUp => write!(f, "mouseup"),
23 NativeEventName::MouseMove => write!(f, "mousemove"),
24 NativeEventName::MouseEnter => write!(f, "mouseenter"),
25 NativeEventName::MouseLeave => write!(f, "mouseleave"),
26 NativeEventName::MouseOver => write!(f, "mouseover"),
27 NativeEventName::MouseOut => write!(f, "mouseout"),
28 NativeEventName::ContextMenu => write!(f, "contextmenu"),
29 NativeEventName::Input => write!(f, "input"),
30 NativeEventName::KeyDown => write!(f, "keydown"),
31 NativeEventName::KeyUp => write!(f, "keyup"),
32 NativeEventName::KeyPress => write!(f, "keypress"),
33 NativeEventName::Focus => write!(f, "focus"),
34 NativeEventName::Blur => write!(f, "blur"),
35 NativeEventName::FocusIn => write!(f, "focusin"),
36 NativeEventName::FocusOut => write!(f, "focusout"),
37 NativeEventName::Submit => write!(f, "submit"),
38 NativeEventName::Change => write!(f, "change"),
39 NativeEventName::Drag => write!(f, "drag"),
40 NativeEventName::DragStart => write!(f, "dragstart"),
41 NativeEventName::DragEnd => write!(f, "dragend"),
42 NativeEventName::DragOver => write!(f, "dragover"),
43 NativeEventName::DragEnter => write!(f, "dragenter"),
44 NativeEventName::DragLeave => write!(f, "dragleave"),
45 NativeEventName::Drop => write!(f, "drop"),
46 NativeEventName::TouchStart => write!(f, "touchstart"),
47 NativeEventName::TouchEnd => write!(f, "touchend"),
48 NativeEventName::TouchMove => write!(f, "touchmove"),
49 NativeEventName::TouchCancel => write!(f, "touchcancel"),
50 NativeEventName::Wheel => write!(f, "wheel"),
51 NativeEventName::Copy => write!(f, "copy"),
52 NativeEventName::Cut => write!(f, "cut"),
53 NativeEventName::Paste => write!(f, "paste"),
54 NativeEventName::Play => write!(f, "play"),
55 NativeEventName::Pause => write!(f, "pause"),
56 NativeEventName::Ended => write!(f, "ended"),
57 NativeEventName::LoadedData => write!(f, "loadeddata"),
58 NativeEventName::CanPlay => write!(f, "canplay"),
59 NativeEventName::VolumeChange => write!(f, "volumechange"),
60 NativeEventName::TimeUpdate => write!(f, "timeupdate"),
61 NativeEventName::HashChange => write!(f, "hashchange"),
62 NativeEventName::PopState => write!(f, "popstate"),
63 NativeEventName::Resize => write!(f, "resize"),
64 NativeEventName::Scroll => write!(f, "scroll"),
65 NativeEventName::Load => write!(f, "load"),
66 NativeEventName::Unload => write!(f, "unload"),
67 NativeEventName::BeforeUnload => write!(f, "beforeunload"),
68 NativeEventName::Error => write!(f, "error"),
69 NativeEventName::Online => write!(f, "online"),
70 NativeEventName::Offline => write!(f, "offline"),
71 NativeEventName::VisibilityChange => write!(f, "visibilitychange"),
72 NativeEventName::AnimationStart => write!(f, "animationstart"),
73 NativeEventName::AnimationEnd => write!(f, "animationend"),
74 NativeEventName::AnimationIteration => write!(f, "animationiteration"),
75 NativeEventName::TransitionStart => write!(f, "transitionstart"),
76 NativeEventName::TransitionEnd => write!(f, "transitionend"),
77 NativeEventName::TransitionRun => write!(f, "transitionrun"),
78 NativeEventName::EuvSignalUpdate => write!(f, "__euv_signal_update__"),
79 NativeEventName::Other(name) => write!(f, "{}", name),
80 }
81 }
82}
83
84impl std::str::FromStr for NativeEventName {
107 type Err = ParseNativeEventNameError;
108
109 fn from_str(data: &str) -> Result<Self, Self::Err> {
120 match data {
121 "click" => Ok(NativeEventName::Click),
122 "dblclick" => Ok(NativeEventName::DblClick),
123 "mousedown" => Ok(NativeEventName::MouseDown),
124 "mouseup" => Ok(NativeEventName::MouseUp),
125 "mousemove" => Ok(NativeEventName::MouseMove),
126 "mouseenter" => Ok(NativeEventName::MouseEnter),
127 "mouseleave" => Ok(NativeEventName::MouseLeave),
128 "mouseover" => Ok(NativeEventName::MouseOver),
129 "mouseout" => Ok(NativeEventName::MouseOut),
130 "contextmenu" => Ok(NativeEventName::ContextMenu),
131 "input" => Ok(NativeEventName::Input),
132 "keydown" => Ok(NativeEventName::KeyDown),
133 "keyup" => Ok(NativeEventName::KeyUp),
134 "keypress" => Ok(NativeEventName::KeyPress),
135 "focus" => Ok(NativeEventName::Focus),
136 "blur" => Ok(NativeEventName::Blur),
137 "focusin" => Ok(NativeEventName::FocusIn),
138 "focusout" => Ok(NativeEventName::FocusOut),
139 "submit" => Ok(NativeEventName::Submit),
140 "change" => Ok(NativeEventName::Change),
141 "drag" => Ok(NativeEventName::Drag),
142 "dragstart" => Ok(NativeEventName::DragStart),
143 "dragend" => Ok(NativeEventName::DragEnd),
144 "dragover" => Ok(NativeEventName::DragOver),
145 "dragenter" => Ok(NativeEventName::DragEnter),
146 "dragleave" => Ok(NativeEventName::DragLeave),
147 "drop" => Ok(NativeEventName::Drop),
148 "touchstart" => Ok(NativeEventName::TouchStart),
149 "touchend" => Ok(NativeEventName::TouchEnd),
150 "touchmove" => Ok(NativeEventName::TouchMove),
151 "touchcancel" => Ok(NativeEventName::TouchCancel),
152 "wheel" => Ok(NativeEventName::Wheel),
153 "copy" => Ok(NativeEventName::Copy),
154 "cut" => Ok(NativeEventName::Cut),
155 "paste" => Ok(NativeEventName::Paste),
156 "play" => Ok(NativeEventName::Play),
157 "pause" => Ok(NativeEventName::Pause),
158 "ended" => Ok(NativeEventName::Ended),
159 "loadeddata" => Ok(NativeEventName::LoadedData),
160 "canplay" => Ok(NativeEventName::CanPlay),
161 "volumechange" => Ok(NativeEventName::VolumeChange),
162 "timeupdate" => Ok(NativeEventName::TimeUpdate),
163 "hashchange" => Ok(NativeEventName::HashChange),
164 "popstate" => Ok(NativeEventName::PopState),
165 "resize" => Ok(NativeEventName::Resize),
166 "scroll" => Ok(NativeEventName::Scroll),
167 "load" => Ok(NativeEventName::Load),
168 "unload" => Ok(NativeEventName::Unload),
169 "beforeunload" => Ok(NativeEventName::BeforeUnload),
170 "error" => Ok(NativeEventName::Error),
171 "online" => Ok(NativeEventName::Online),
172 "offline" => Ok(NativeEventName::Offline),
173 "visibilitychange" => Ok(NativeEventName::VisibilityChange),
174 "animationstart" => Ok(NativeEventName::AnimationStart),
175 "animationend" => Ok(NativeEventName::AnimationEnd),
176 "animationiteration" => Ok(NativeEventName::AnimationIteration),
177 "transitionstart" => Ok(NativeEventName::TransitionStart),
178 "transitionend" => Ok(NativeEventName::TransitionEnd),
179 "transitionrun" => Ok(NativeEventName::TransitionRun),
180 "" => Err(ParseNativeEventNameError::new(data.to_string())),
181 other => Ok(NativeEventName::Other(other.to_string())),
182 }
183 }
184}