field_kinds/field_meta/
categories.rs1use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
2
3pub trait TypeCategory: 'static + Copy {
7 const NAME: &'static str;
9}
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub struct Numeric;
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub struct Text;
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21pub struct Bool;
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub struct Optional;
26
27#[derive(Debug, Clone, Copy, PartialEq, Eq)]
29pub struct Collection;
30
31#[derive(Debug, Clone, Copy, PartialEq, Eq)]
33pub struct Unknown;
34
35impl TypeCategory for Numeric {
36 const NAME: &'static str = "numeric";
37}
38impl TypeCategory for Text {
39 const NAME: &'static str = "text";
40}
41impl TypeCategory for Bool {
42 const NAME: &'static str = "bool";
43}
44impl TypeCategory for Optional {
45 const NAME: &'static str = "optional";
46}
47impl TypeCategory for Collection {
48 const NAME: &'static str = "collection";
49}
50impl TypeCategory for Unknown {
51 const NAME: &'static str = "unknown";
52}
53
54pub trait Categorized {
70 type Category: TypeCategory;
72}
73
74impl Categorized for u8 {
75 type Category = Numeric;
76}
77impl Categorized for u16 {
78 type Category = Numeric;
79}
80impl Categorized for u32 {
81 type Category = Numeric;
82}
83impl Categorized for u64 {
84 type Category = Numeric;
85}
86impl Categorized for u128 {
87 type Category = Numeric;
88}
89impl Categorized for usize {
90 type Category = Numeric;
91}
92
93impl Categorized for i8 {
94 type Category = Numeric;
95}
96impl Categorized for i16 {
97 type Category = Numeric;
98}
99impl Categorized for i32 {
100 type Category = Numeric;
101}
102impl Categorized for i64 {
103 type Category = Numeric;
104}
105impl Categorized for i128 {
106 type Category = Numeric;
107}
108impl Categorized for isize {
109 type Category = Numeric;
110}
111
112impl Categorized for f32 {
113 type Category = Numeric;
114}
115impl Categorized for f64 {
116 type Category = Numeric;
117}
118
119impl Categorized for String {
120 type Category = Text;
121}
122impl Categorized for &str {
123 type Category = Text;
124}
125impl Categorized for Box<str> {
126 type Category = Text;
127}
128impl Categorized for char {
129 type Category = Text;
130}
131
132impl Categorized for bool {
133 type Category = Bool;
134}
135
136impl<T> Categorized for Option<T> {
137 type Category = Optional;
138}
139
140impl<T> Categorized for Vec<T> {
141 type Category = Collection;
142}
143impl<T, const N: usize> Categorized for [T; N] {
144 type Category = Collection;
145}
146impl<T> Categorized for &[T] {
147 type Category = Collection;
148}
149impl<T, S> Categorized for HashSet<T, S> {
150 type Category = Collection;
151}
152impl<T> Categorized for BTreeSet<T> {
153 type Category = Collection;
154}
155impl<K, V, S> Categorized for HashMap<K, V, S> {
156 type Category = Collection;
157}
158impl<K, V> Categorized for BTreeMap<K, V> {
159 type Category = Collection;
160}