aws_smithy_schema/schema/
prelude.rs1use crate::{shape_id, Schema, ShapeType};
12
13pub static STRING: Schema<'static> =
15 Schema::new(shape_id!("smithy.api", "String"), ShapeType::String);
16
17pub static BOOLEAN: Schema<'static> =
19 Schema::new(shape_id!("smithy.api", "Boolean"), ShapeType::Boolean);
20
21pub static BYTE: Schema<'static> = Schema::new(shape_id!("smithy.api", "Byte"), ShapeType::Byte);
23
24pub static SHORT: Schema<'static> = Schema::new(shape_id!("smithy.api", "Short"), ShapeType::Short);
26
27pub static INTEGER: Schema<'static> =
29 Schema::new(shape_id!("smithy.api", "Integer"), ShapeType::Integer);
30
31pub static LONG: Schema<'static> = Schema::new(shape_id!("smithy.api", "Long"), ShapeType::Long);
33
34pub static FLOAT: Schema<'static> = Schema::new(shape_id!("smithy.api", "Float"), ShapeType::Float);
36
37pub static DOUBLE: Schema<'static> =
39 Schema::new(shape_id!("smithy.api", "Double"), ShapeType::Double);
40
41pub static BIG_INTEGER: Schema<'static> =
43 Schema::new(shape_id!("smithy.api", "BigInteger"), ShapeType::BigInteger);
44
45pub static BIG_DECIMAL: Schema<'static> =
47 Schema::new(shape_id!("smithy.api", "BigDecimal"), ShapeType::BigDecimal);
48
49pub static BLOB: Schema<'static> = Schema::new(shape_id!("smithy.api", "Blob"), ShapeType::Blob);
51
52pub static TIMESTAMP: Schema<'static> =
54 Schema::new(shape_id!("smithy.api", "Timestamp"), ShapeType::Timestamp);
55
56pub static DOCUMENT: Schema<'static> =
58 Schema::new(shape_id!("smithy.api", "Document"), ShapeType::Document);
59
60pub static UNIT: Schema<'static> =
62 Schema::new_struct(shape_id!("smithy.api", "Unit"), ShapeType::Structure, &[]);
63
64#[cfg(test)]
65mod tests {
66 use super::*;
67
68 #[test]
69 fn test_string_schema() {
70 assert_eq!(STRING.shape_id().as_str(), "smithy.api#String");
71 assert_eq!(STRING.shape_type(), ShapeType::String);
72 assert!(STRING.is_string());
73 assert!(STRING.traits().is_none());
74 }
75
76 #[test]
77 fn test_boolean_schema() {
78 assert_eq!(BOOLEAN.shape_id().as_str(), "smithy.api#Boolean");
79 assert_eq!(BOOLEAN.shape_type(), ShapeType::Boolean);
80 assert!(BOOLEAN.traits().is_none());
81 }
82
83 #[test]
84 fn test_numeric_schemas() {
85 assert_eq!(BYTE.shape_type(), ShapeType::Byte);
86 assert_eq!(SHORT.shape_type(), ShapeType::Short);
87 assert_eq!(INTEGER.shape_type(), ShapeType::Integer);
88 assert_eq!(LONG.shape_type(), ShapeType::Long);
89 assert_eq!(FLOAT.shape_type(), ShapeType::Float);
90 assert_eq!(DOUBLE.shape_type(), ShapeType::Double);
91 assert_eq!(BIG_INTEGER.shape_type(), ShapeType::BigInteger);
92 assert_eq!(BIG_DECIMAL.shape_type(), ShapeType::BigDecimal);
93 }
94
95 #[test]
96 fn test_blob_schema() {
97 assert_eq!(BLOB.shape_id().as_str(), "smithy.api#Blob");
98 assert_eq!(BLOB.shape_type(), ShapeType::Blob);
99 assert!(BLOB.is_blob());
100 }
101
102 #[test]
103 fn test_timestamp_schema() {
104 assert_eq!(TIMESTAMP.shape_id().as_str(), "smithy.api#Timestamp");
105 assert_eq!(TIMESTAMP.shape_type(), ShapeType::Timestamp);
106 }
107
108 #[test]
109 fn test_document_schema() {
110 assert_eq!(DOCUMENT.shape_id().as_str(), "smithy.api#Document");
111 assert_eq!(DOCUMENT.shape_type(), ShapeType::Document);
112 }
113
114 #[test]
115 fn test_all_prelude_types_are_simple() {
116 assert!(STRING.shape_type().is_simple());
117 assert!(BOOLEAN.shape_type().is_simple());
118 assert!(BYTE.shape_type().is_simple());
119 assert!(SHORT.shape_type().is_simple());
120 assert!(INTEGER.shape_type().is_simple());
121 assert!(LONG.shape_type().is_simple());
122 assert!(FLOAT.shape_type().is_simple());
123 assert!(DOUBLE.shape_type().is_simple());
124 assert!(BIG_INTEGER.shape_type().is_simple());
125 assert!(BIG_DECIMAL.shape_type().is_simple());
126 assert!(BLOB.shape_type().is_simple());
127 assert!(TIMESTAMP.shape_type().is_simple());
128 assert!(DOCUMENT.shape_type().is_simple());
129 }
130}