stargate_grpc/
types.rs

1//! Structs for describing the types of gRPC data values
2//!
3//! These structs do not hold any data, they exist purely for
4//! describing types. They are needed for constructing type parameters passed to
5//! [`Value::of_type`](crate::Value::of_type) or [`Value::list_of`](crate::Value::list_of)
6//! functions.
7//!
8//! # Example
9//! ```
10//! use stargate_grpc::types;
11//!
12//! let int_type = types::Bigint;
13//! let list_of_ints = types::List(types::Bigint);
14//! let list_of_tuples = types::List((types::Bigint, types::Text));
15//! let map_from_uuid_to_user_type = types::Map(types::Uuid, types::Udt);
16//! ```
17
18/// Must be implemented by all types except Any.
19pub trait ConcreteType {}
20
21pub struct Bigint;
22impl ConcreteType for Bigint {}
23
24pub struct Boolean;
25impl ConcreteType for Boolean {}
26
27pub struct Blob;
28impl ConcreteType for Blob {}
29
30pub struct Counter;
31impl ConcreteType for Counter {}
32
33pub struct Date;
34impl ConcreteType for Date {}
35
36pub struct Decimal;
37impl ConcreteType for Decimal {}
38
39pub struct Double;
40impl ConcreteType for Double {}
41
42pub struct Float;
43impl ConcreteType for Float {}
44
45pub struct Inet;
46impl ConcreteType for Inet {}
47
48pub struct Int;
49impl ConcreteType for Int {}
50
51pub struct Smallint;
52impl ConcreteType for Smallint {}
53
54pub struct Text;
55impl ConcreteType for Text {}
56
57pub struct Time;
58impl ConcreteType for Time {}
59
60pub struct Timestamp;
61impl ConcreteType for Timestamp {}
62
63pub struct Tinyint;
64impl ConcreteType for Tinyint {}
65
66pub struct Udt;
67impl ConcreteType for Udt {}
68
69pub struct Uuid;
70impl ConcreteType for Uuid {}
71
72pub struct Varchar;
73impl ConcreteType for Varchar {}
74
75pub struct Varint;
76impl ConcreteType for Varint {}
77
78pub struct List<T>(pub T);
79impl<T> ConcreteType for List<T> {}
80
81pub struct Set<T>(pub T);
82impl<T> ConcreteType for Set<T> {}
83
84pub struct Map<K, V>(pub K, pub V);
85impl<K, V> ConcreteType for Map<K, V> {}
86
87/// Used in target type specification passed to [`Value::of_type`](crate::Value::of_type)
88/// to mark that the conversion should generate a `Value` of the default type.
89/// It is handy if we already have a `Value` in the structure to be converted, and we
90/// just want it to be passed-through.
91pub struct Any;