planetscale_driver/
parser.rs

1use anyhow::Result;
2
3pub trait Parser {
4    fn custom_parse(input: &str) -> Result<Self>
5    where
6        Self: Sized;
7}
8
9impl Parser for String {
10    fn custom_parse(input: &str) -> Result<Self> {
11        Ok(input.to_string())
12    }
13}
14
15impl Parser for isize {
16    fn custom_parse(input: &str) -> Result<Self> {
17        Ok(input.parse()?)
18    }
19}
20
21impl Parser for i128 {
22    fn custom_parse(input: &str) -> Result<Self> {
23        Ok(input.parse()?)
24    }
25}
26
27impl Parser for i64 {
28    fn custom_parse(input: &str) -> Result<Self> {
29        Ok(input.parse()?)
30    }
31}
32
33impl Parser for i32 {
34    fn custom_parse(input: &str) -> Result<Self> {
35        Ok(input.parse()?)
36    }
37}
38
39impl Parser for i16 {
40    fn custom_parse(input: &str) -> Result<Self> {
41        Ok(input.parse()?)
42    }
43}
44
45impl Parser for i8 {
46    fn custom_parse(input: &str) -> Result<Self> {
47        Ok(input.parse()?)
48    }
49}
50
51impl Parser for usize {
52    fn custom_parse(input: &str) -> Result<Self> {
53        Ok(input.parse()?)
54    }
55}
56
57impl Parser for u128 {
58    fn custom_parse(input: &str) -> Result<Self> {
59        Ok(input.parse()?)
60    }
61}
62
63impl Parser for u64 {
64    fn custom_parse(input: &str) -> Result<Self> {
65        Ok(input.parse()?)
66    }
67}
68
69impl Parser for u32 {
70    fn custom_parse(input: &str) -> Result<Self> {
71        Ok(input.parse()?)
72    }
73}
74
75impl Parser for u16 {
76    fn custom_parse(input: &str) -> Result<Self> {
77        Ok(input.parse()?)
78    }
79}
80
81impl Parser for u8 {
82    fn custom_parse(input: &str) -> Result<Self> {
83        Ok(input.parse()?)
84    }
85}
86
87impl Parser for f64 {
88    fn custom_parse(input: &str) -> Result<Self> {
89        Ok(input.parse()?)
90    }
91}
92
93impl Parser for f32 {
94    fn custom_parse(input: &str) -> Result<Self> {
95        Ok(input.parse()?)
96    }
97}
98
99impl Parser for bool {
100    fn custom_parse(input: &str) -> Result<Self> {
101        match input {
102            "1" => Ok(true),
103            "0" => Ok(false),
104            _ => Err(anyhow::anyhow!("Invalid boolean")),
105        }
106    }
107}
108
109impl Parser for char {
110    fn custom_parse(input: &str) -> Result<Self> {
111        Ok(input.parse()?)
112    }
113}