| 946 | type Err = PlanError; |
| 947 | |
| 948 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 949 | let err = || PlanError::Unstructured(format!("couldn't parse SchemaId {}", s)); |
| 950 | // Validate the (single-byte, ASCII) tag before slicing so that a |
| 951 | // multi-byte leading character doesn't slice inside a UTF-8 boundary. |
| 952 | let variant = match s.chars().next() { |
| 953 | Some('s') => SchemaId::System, |
| 954 | Some('u') => SchemaId::User, |
| 955 | _ => return Err(err()), |
| 956 | }; |
| 957 | let val: u64 = s[1..].parse().map_err(|_| err())?; |
| 958 | Ok(variant(val)) |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | /// The identifier for a database. |