forked from feather-rs/feather
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathevents.rs
More file actions
41 lines (37 loc) · 1.09 KB
/
Copy pathevents.rs
File metadata and controls
41 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#[derive(Debug, Clone)]
pub enum EventParseError<'a> {
InvalidEventType(&'a str),
InvalidEventAction(&'a str),
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum EventType {
OnHover,
OnClick,
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum EventAction {
ShowText,
OpenUrl,
OpenFile,
RunCommand,
SuggestCommand,
CopyToClipboard,
}
pub fn parse_event_type_word(i: &str) -> Result<EventType, EventParseError> {
match i {
"on_hover" => Ok(EventType::OnHover),
"on_click" => Ok(EventType::OnClick),
_ => Err(EventParseError::InvalidEventType(i)),
}
}
pub fn parse_event_action_word(i: &str) -> Result<EventAction, EventParseError> {
match i {
"show_text" => Ok(EventAction::ShowText),
"open_url" => Ok(EventAction::OpenUrl),
"open_file" => Ok(EventAction::OpenFile),
"run_command" => Ok(EventAction::RunCommand),
"suggest_command" => Ok(EventAction::SuggestCommand),
"copy_to_clipboard" => Ok(EventAction::CopyToClipboard),
_ => Err(EventParseError::InvalidEventAction(i)),
}
}