things3_cloud/
arg_types.rs1use std::{fmt, str::FromStr};
2
3#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4pub struct IdentifierToken(String);
5
6impl IdentifierToken {
7 pub fn as_str(&self) -> &str {
8 &self.0
9 }
10
11 pub fn into_inner(self) -> String {
12 self.0
13 }
14}
15
16impl FromStr for IdentifierToken {
17 type Err = String;
18
19 fn from_str(value: &str) -> Result<Self, Self::Err> {
20 let value = value.trim();
21 if value.is_empty() {
22 return Err("identifier cannot be empty".to_string());
23 }
24 Ok(Self(value.to_string()))
25 }
26}
27
28impl From<String> for IdentifierToken {
29 fn from(value: String) -> Self {
30 Self(value)
31 }
32}
33
34impl From<&str> for IdentifierToken {
35 fn from(value: &str) -> Self {
36 Self(value.to_string())
37 }
38}
39
40impl fmt::Display for IdentifierToken {
41 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42 write!(f, "{}", self.0)
43 }
44}