freya_core/values/
accessibility.rs

1use accesskit::{
2    Action,
3    AriaCurrent,
4    AutoComplete,
5    HasPopup,
6    Invalid,
7    ListStyle,
8    Live,
9    Orientation,
10    Role,
11    SortDirection,
12    Toggled,
13    VerticalOffset,
14};
15
16use crate::parsing::{
17    Parse,
18    ParseError,
19};
20
21impl Parse for Role {
22    fn parse(value: &str) -> Result<Self, ParseError> {
23        Ok(match value {
24            "unknown" => Self::Unknown,
25            "cell" => Self::Cell,
26            "label" => Self::Label,
27            "image" => Self::Image,
28            "link" => Self::Link,
29            "row" => Self::Row,
30            "list-item" => Self::ListItem,
31            "list-marker" => Self::ListMarker,
32            "tree-item" => Self::TreeItem,
33            "list-box-option" => Self::ListBoxOption,
34            "menu-item" => Self::MenuItem,
35            "menu-list-option" => Self::MenuListOption,
36            "paragraph" => Self::Paragraph,
37            "generic-container" => Self::GenericContainer,
38            "check-box" => Self::CheckBox,
39            "radio-button" => Self::RadioButton,
40            "text-input" => Self::TextInput,
41            "button" => Self::Button,
42            "default-button" => Self::DefaultButton,
43            "pane" => Self::Pane,
44            "row-header" => Self::RowHeader,
45            "column-header" => Self::ColumnHeader,
46            "row-group" => Self::RowGroup,
47            "list" => Self::List,
48            "table" => Self::Table,
49            "layout-table-cell" => Self::LayoutTableCell,
50            "layout-table-row" => Self::LayoutTableRow,
51            "layout-table" => Self::LayoutTable,
52            "switch" => Self::Switch,
53            "menu" => Self::Menu,
54            "multiline-text-input" => Self::MultilineTextInput,
55            "search-input" => Self::SearchInput,
56            "date-input" => Self::DateInput,
57            "date-time-input" => Self::DateTimeInput,
58            "week-input" => Self::WeekInput,
59            "month-input" => Self::MonthInput,
60            "time-input" => Self::TimeInput,
61            "email-input" => Self::EmailInput,
62            "number-input" => Self::NumberInput,
63            "password-input" => Self::PasswordInput,
64            "phone-number-input" => Self::PhoneNumberInput,
65            "url-input" => Self::UrlInput,
66            "abbr" => Self::Abbr,
67            "alert" => Self::Alert,
68            "alert-dialog" => Self::AlertDialog,
69            "application" => Self::Application,
70            "article" => Self::Article,
71            "audio" => Self::Audio,
72            "banner" => Self::Banner,
73            "blockquote" => Self::Blockquote,
74            "canvas" => Self::Canvas,
75            "caption" => Self::Caption,
76            "caret" => Self::Caret,
77            "code" => Self::Code,
78            "color-well" => Self::ColorWell,
79            "combo-box" => Self::ComboBox,
80            "editable-combo-box" => Self::EditableComboBox,
81            "complementary" => Self::Complementary,
82            "comment" => Self::Comment,
83            "content-deletion" => Self::ContentDeletion,
84            "content-insertion" => Self::ContentInsertion,
85            "content-info" => Self::ContentInfo,
86            "definition" => Self::Definition,
87            "description-list" => Self::DescriptionList,
88            "description-list-detail" => Self::DescriptionListDetail,
89            "description-list-term" => Self::DescriptionListTerm,
90            "details" => Self::Details,
91            "dialog" => Self::Dialog,
92            "directory" => Self::Directory,
93            "disclosure-triangle" => Self::DisclosureTriangle,
94            "document" => Self::Document,
95            "embedded-object" => Self::EmbeddedObject,
96            "emphasis" => Self::Emphasis,
97            "feed" => Self::Feed,
98            "figure-caption" => Self::FigureCaption,
99            "figure" => Self::Figure,
100            "footer" => Self::Footer,
101            "footer-as-non-landmark" => Self::FooterAsNonLandmark,
102            "form" => Self::Form,
103            "grid" => Self::Grid,
104            "group" => Self::Group,
105            "header" => Self::Header,
106            "header-as-non-landmark" => Self::HeaderAsNonLandmark,
107            "heading" => Self::Heading,
108            "iframe" => Self::Iframe,
109            "iframe-presentational" => Self::IframePresentational,
110            "ime-candidate" => Self::ImeCandidate,
111            "keyboard" => Self::Keyboard,
112            "legend" => Self::Legend,
113            "line-break" => Self::LineBreak,
114            "list-box" => Self::ListBox,
115            "log" => Self::Log,
116            "main" => Self::Main,
117            "mark" => Self::Mark,
118            "marquee" => Self::Marquee,
119            "math" => Self::Math,
120            "menu-bar" => Self::MenuBar,
121            "menu-item-check-box" => Self::MenuItemCheckBox,
122            "menu-item-radio" => Self::MenuItemRadio,
123            "menu-list-popup" => Self::MenuListPopup,
124            "meter" => Self::Meter,
125            "navigation" => Self::Navigation,
126            "note" => Self::Note,
127            "plugin-object" => Self::PluginObject,
128            "portal" => Self::Portal,
129            "pre" => Self::Pre,
130            "progress-indicator" => Self::ProgressIndicator,
131            "radio-group" => Self::RadioGroup,
132            "region" => Self::Region,
133            "root-web-area" => Self::RootWebArea,
134            "ruby" => Self::Ruby,
135            "ruby-annotation" => Self::RubyAnnotation,
136            "scroll-bar" => Self::ScrollBar,
137            "scroll-view" => Self::ScrollView,
138            "search" => Self::Search,
139            "section" => Self::Section,
140            "slider" => Self::Slider,
141            "spin-button" => Self::SpinButton,
142            "splitter" => Self::Splitter,
143            "status" => Self::Status,
144            "strong" => Self::Strong,
145            "suggestion" => Self::Suggestion,
146            "svg-root" => Self::SvgRoot,
147            "tab" => Self::Tab,
148            "tab-list" => Self::TabList,
149            "tab-panel" => Self::TabPanel,
150            "term" => Self::Term,
151            "time" => Self::Time,
152            "timer" => Self::Timer,
153            "title-bar" => Self::TitleBar,
154            "toolbar" => Self::Toolbar,
155            "tooltip" => Self::Tooltip,
156            "tree" => Self::Tree,
157            "tree-grid" => Self::TreeGrid,
158            "video" => Self::Video,
159            "web-view" => Self::WebView,
160            "window" => Self::Window,
161            "pdf-actionable-highlight" => Self::PdfActionableHighlight,
162            "pdf-root" => Self::PdfRoot,
163            "graphics-document" => Self::GraphicsDocument,
164            "graphics-object" => Self::GraphicsObject,
165            "graphics-symbol" => Self::GraphicsSymbol,
166            "doc-abstract" => Self::DocAbstract,
167            "doc-acknowledgements" => Self::DocAcknowledgements,
168            "doc-afterword" => Self::DocAfterword,
169            "doc-appendix" => Self::DocAppendix,
170            "doc-back-link" => Self::DocBackLink,
171            "doc-biblio-entry" => Self::DocBiblioEntry,
172            "doc-bibliography" => Self::DocBibliography,
173            "doc-biblio-ref" => Self::DocBiblioRef,
174            "doc-chapter" => Self::DocChapter,
175            "doc-colophon" => Self::DocColophon,
176            "doc-conclusion" => Self::DocConclusion,
177            "doc-cover" => Self::DocCover,
178            "doc-credit" => Self::DocCredit,
179            "doc-credits" => Self::DocCredits,
180            "doc-dedication" => Self::DocDedication,
181            "doc-endnote" => Self::DocEndnote,
182            "doc-endnotes" => Self::DocEndnotes,
183            "doc-epigraph" => Self::DocEpigraph,
184            "doc-epilogue" => Self::DocEpilogue,
185            "doc-errata" => Self::DocErrata,
186            "doc-example" => Self::DocExample,
187            "doc-footnote" => Self::DocFootnote,
188            "doc-foreword" => Self::DocForeword,
189            "doc-glossary" => Self::DocGlossary,
190            "doc-gloss-ref" => Self::DocGlossRef,
191            "doc-index" => Self::DocIndex,
192            "doc-introduction" => Self::DocIntroduction,
193            "doc-note-ref" => Self::DocNoteRef,
194            "doc-notice" => Self::DocNotice,
195            "doc-page-break" => Self::DocPageBreak,
196            "doc-page-footer" => Self::DocPageFooter,
197            "doc-page-header" => Self::DocPageHeader,
198            "doc-page-list" => Self::DocPageList,
199            "doc-part" => Self::DocPart,
200            "doc-preface" => Self::DocPreface,
201            "doc-prologue" => Self::DocPrologue,
202            "doc-pullquote" => Self::DocPullquote,
203            "doc-qna" => Self::DocQna,
204            "doc-subtitle" => Self::DocSubtitle,
205            "doc-tip" => Self::DocTip,
206            "doc-toc" => Self::DocToc,
207            "list-grid" => Self::ListGrid,
208            "terminal" => Self::Terminal,
209            _ => Err(ParseError)?,
210        })
211    }
212}
213
214impl Parse for Invalid {
215    fn parse(value: &str) -> Result<Self, ParseError> {
216        Ok(match value {
217            "true" => Invalid::True,
218            "grammar" => Invalid::Grammar,
219            "spelling" => Invalid::Spelling,
220            _ => Err(ParseError)?,
221        })
222    }
223}
224
225impl Parse for Toggled {
226    fn parse(value: &str) -> Result<Self, ParseError> {
227        Ok(match value {
228            "true" => Toggled::True,
229            "false" => Toggled::False,
230            "mixed" => Toggled::Mixed,
231            _ => Err(ParseError)?,
232        })
233    }
234}
235
236impl Parse for Live {
237    fn parse(value: &str) -> Result<Self, ParseError> {
238        Ok(match value {
239            "assertive" => Live::Assertive,
240            "off" => Live::Off,
241            "polite" => Live::Polite,
242            _ => Err(ParseError)?,
243        })
244    }
245}
246
247impl Parse for Action {
248    fn parse(value: &str) -> Result<Self, ParseError> {
249        Ok(match value {
250            "click" => Action::Click,
251            "focus" => Action::Focus,
252            "blur" => Action::Blur,
253            "collapse" => Action::Collapse,
254            "expand" => Action::Expand,
255            "custom-action" => Action::CustomAction,
256            "decrement" => Action::Decrement,
257            "increment" => Action::Increment,
258            "hide-tooltip" => Action::HideTooltip,
259            "show-tooltip" => Action::ShowTooltip,
260            "replace-selected-text" => Action::ReplaceSelectedText,
261            "scroll-backward" => Action::ScrollBackward,
262            "scroll-down" => Action::ScrollDown,
263            "scroll-forward" => Action::ScrollForward,
264            "scroll-left" => Action::ScrollLeft,
265            "scroll-right" => Action::ScrollRight,
266            "scroll-up" => Action::ScrollUp,
267            "scroll-into-view" => Action::ScrollIntoView,
268            "scroll-to-point" => Action::ScrollToPoint,
269            "set-scroll-offset" => Action::SetScrollOffset,
270            "set-text-selection" => Action::SetTextSelection,
271            "set-sequential-focus-navigation-starting-point" => {
272                Action::SetSequentialFocusNavigationStartingPoint
273            }
274            "set-value" => Action::SetValue,
275            "show-context-menu" => Action::ShowContextMenu,
276            _ => Err(ParseError)?,
277        })
278    }
279}
280
281impl Parse for Orientation {
282    fn parse(value: &str) -> Result<Self, ParseError> {
283        Ok(match value {
284            "horizontal" => Orientation::Horizontal,
285            "vertical" => Orientation::Vertical,
286            _ => Err(ParseError)?,
287        })
288    }
289}
290
291impl Parse for SortDirection {
292    fn parse(value: &str) -> Result<Self, ParseError> {
293        Ok(match value {
294            "ascending" => SortDirection::Ascending,
295            "descending" => SortDirection::Descending,
296            "other" => SortDirection::Other,
297            _ => Err(ParseError)?,
298        })
299    }
300}
301
302impl Parse for AriaCurrent {
303    fn parse(value: &str) -> Result<Self, ParseError> {
304        Ok(match value {
305            "false" => AriaCurrent::False,
306            "true" => AriaCurrent::True,
307            "page" => AriaCurrent::Page,
308            "step" => AriaCurrent::Step,
309            "location" => AriaCurrent::Location,
310            "date" => AriaCurrent::Date,
311            "time" => AriaCurrent::Time,
312            _ => Err(ParseError)?,
313        })
314    }
315}
316
317impl Parse for AutoComplete {
318    fn parse(value: &str) -> Result<Self, ParseError> {
319        Ok(match value {
320            "inline" => AutoComplete::Inline,
321            "list" => AutoComplete::List,
322            "both" => AutoComplete::Both,
323            _ => Err(ParseError)?,
324        })
325    }
326}
327
328impl Parse for HasPopup {
329    fn parse(value: &str) -> Result<Self, ParseError> {
330        Ok(match value {
331            "menu" => HasPopup::Menu,
332            "listbox" => HasPopup::Listbox,
333            "tree" => HasPopup::Tree,
334            "grid" => HasPopup::Grid,
335            "dialog" => HasPopup::Dialog,
336            _ => Err(ParseError)?,
337        })
338    }
339}
340
341impl Parse for ListStyle {
342    fn parse(value: &str) -> Result<Self, ParseError> {
343        Ok(match value {
344            "circle" => ListStyle::Circle,
345            "disc" => ListStyle::Disc,
346            "image" => ListStyle::Image,
347            "numeric" => ListStyle::Numeric,
348            "square" => ListStyle::Square,
349            "other" => ListStyle::Other,
350            _ => Err(ParseError)?,
351        })
352    }
353}
354
355impl Parse for VerticalOffset {
356    fn parse(value: &str) -> Result<Self, ParseError> {
357        Ok(match value {
358            "subscript" => VerticalOffset::Subscript,
359            "superscript" => VerticalOffset::Superscript,
360            _ => Err(ParseError)?,
361        })
362    }
363}