1use crate::{Error, Result, URTypeString};
2
3#[derive(Debug, Clone, PartialEq)]
4pub struct URType(String);
5
6impl URType {
7 pub fn new(ur_type: impl Into<String>) -> Result<URType> {
9 let ur_type = ur_type.into();
10 if !ur_type.is_ur_type() {
11 return Err(Error::InvalidType);
12 }
13 Ok(URType(ur_type))
14 }
15
16 pub fn string(&self) -> &str { &self.0 }
18}
19
20impl TryFrom<String> for URType {
21 type Error = Error;
22
23 fn try_from(value: String) -> Result<Self> { URType::new(value) }
24}
25
26impl TryFrom<&str> for URType {
27 type Error = Error;
28
29 fn try_from(value: &str) -> Result<Self> { URType::new(value) }
30}