reifydb_type/value/type/
get.rs

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