xsd_types/lexical/string/
id.rs1use crate::lexical::{Lexical, LexicalFormOf};
2use crate::InvalidId;
3pub use crate::{Id, IdBuf};
4
5impl Lexical for Id {
6 type Error = InvalidId<String>;
7
8 fn parse(value: &str) -> Result<&Self, Self::Error> {
9 Self::new(value).map_err(|_| InvalidId(value.to_owned()))
10 }
11}
12
13impl LexicalFormOf<crate::IdBuf> for Id {
14 type ValueError = InvalidId<String>;
15
16 fn try_as_value(&self) -> Result<crate::IdBuf, Self::ValueError> {
17 self.as_str().parse()
18 }
19}