(input: syn::parse::ParseStream)
| 269 | |
| 270 | impl Parse for SchemaErr { |
| 271 | fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> { |
| 272 | let code = input.parse()?; |
| 273 | |
| 274 | if input.peek(Token![,]) { |
| 275 | input.parse::<Token![,]>()?; |
| 276 | } |
| 277 | |
| 278 | if input.is_empty() { |
| 279 | return Ok(SchemaErr { |
| 280 | code, |
| 281 | message: None, |
| 282 | }); |
| 283 | } |
| 284 | |
| 285 | let message = input.parse()?; |
| 286 | |
| 287 | if input.peek(Token![,]) { |
| 288 | input.parse::<Token![,]>()?; |
| 289 | } |
| 290 | |
| 291 | Ok(SchemaErr { code, message }) |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | /// Designed to be used with the [schema_validation] macro. Used for ergonomic custom error handling. |
no test coverage detected