lambda_appsync/aws_scalars/
mod.rs1macro_rules! impl_new_string {
2 (base $name:ident) => {
3 #[doc = "AWS AppSync specific GraphQL scalar type implemented a [String] new-type"]
4 #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
5 #[serde(transparent)]
6 pub struct $name(String);
7 impl core::ops::Deref for $name {
8 type Target = String;
9
10 fn deref(&self) -> &Self::Target {
11 &self.0
12 }
13 }
14 };
15 (display $name:ident) => {
16 impl core::fmt::Display for $name {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 core::fmt::Display::fmt(&self.0, f)
19 }
20 }
21 };
22 (from $name:ident) => {
23 impl From<String> for $name {
24 fn from(value: String) -> Self {
25 Self(value)
26 }
27 }
28 impl From<&str> for $name {
29 fn from(value: &str) -> Self {
30 Self(value.to_owned())
31 }
32 }
33 };
34 (into $name:ident) => {
35 impl From<$name> for String {
36 fn from(value: $name) -> Self {
37 value.0
38 }
39 }
40 };
41 (no_display $name:ident) => {
42 impl_new_string!(base $name);
43 impl_new_string!(from $name);
44 impl_new_string!(into $name);
45 };
46 (no_from $name:ident) => {
47 impl_new_string!(base $name);
48 impl_new_string!(display $name);
49 impl_new_string!(into $name);
50 };
51 (no_into $name:ident) => {
52 impl_new_string!(base $name);
53 impl_new_string!(display $name);
54 impl_new_string!(from $name);
55 };
56 ($name:ident) => {
57 impl_new_string!(base $name);
58 impl_new_string!(display $name);
59 impl_new_string!(from $name);
60 impl_new_string!(into $name);
61 };
62}
63
64pub mod datetime;
65pub mod email;
66pub mod phone;
67pub mod timestamp;
68pub mod url;