Skip to main content

reifydb_type/value/type/
get.rs

1// SPDX-License-Identifier: MIT
2// Copyright (c) 2025 ReifyDB
3
4use crate::value::{
5	date::Date,
6	datetime::DateTime,
7	decimal::Decimal,
8	duration::Duration,
9	identity::IdentityId,
10	int::Int,
11	time::Time,
12	r#type::Type,
13	uint::Uint,
14	uuid::{Uuid4, Uuid7},
15};
16
17pub trait GetType {
18	fn get_type() -> Type;
19}
20
21impl GetType for bool {
22	fn get_type() -> Type {
23		Type::Boolean
24	}
25}
26
27impl GetType for f32 {
28	fn get_type() -> Type {
29		Type::Float4
30	}
31}
32
33impl GetType for f64 {
34	fn get_type() -> Type {
35		Type::Float8
36	}
37}
38
39impl GetType for i8 {
40	fn get_type() -> Type {
41		Type::Int1
42	}
43}
44
45impl GetType for i16 {
46	fn get_type() -> Type {
47		Type::Int2
48	}
49}
50
51impl GetType for i32 {
52	fn get_type() -> Type {
53		Type::Int4
54	}
55}
56
57impl GetType for i64 {
58	fn get_type() -> Type {
59		Type::Int8
60	}
61}
62
63impl GetType for i128 {
64	fn get_type() -> Type {
65		Type::Int16
66	}
67}
68
69impl GetType for String {
70	fn get_type() -> Type {
71		Type::Utf8
72	}
73}
74
75impl GetType for u8 {
76	fn get_type() -> Type {
77		Type::Uint1
78	}
79}
80
81impl GetType for u16 {
82	fn get_type() -> Type {
83		Type::Uint2
84	}
85}
86
87impl GetType for u32 {
88	fn get_type() -> Type {
89		Type::Uint4
90	}
91}
92
93impl GetType for u64 {
94	fn get_type() -> Type {
95		Type::Uint8
96	}
97}
98
99impl GetType for u128 {
100	fn get_type() -> Type {
101		Type::Uint16
102	}
103}
104
105impl GetType for Date {
106	fn get_type() -> Type {
107		Type::Date
108	}
109}
110
111impl GetType for Time {
112	fn get_type() -> Type {
113		Type::Time
114	}
115}
116
117impl GetType for DateTime {
118	fn get_type() -> Type {
119		Type::DateTime
120	}
121}
122
123impl GetType for Duration {
124	fn get_type() -> Type {
125		Type::Duration
126	}
127}
128
129impl GetType for Uuid4 {
130	fn get_type() -> Type {
131		Type::Uuid4
132	}
133}
134
135impl GetType for IdentityId {
136	fn get_type() -> Type {
137		Type::IdentityId
138	}
139}
140
141impl GetType for Uuid7 {
142	fn get_type() -> Type {
143		Type::Uuid7
144	}
145}
146
147impl GetType for Int {
148	fn get_type() -> Type {
149		Type::Int
150	}
151}
152
153impl GetType for Uint {
154	fn get_type() -> Type {
155		Type::Uint
156	}
157}
158
159impl GetType for Decimal {
160	fn get_type() -> Type {
161		Type::Decimal
162	}
163}