()
| 60 | } |
| 61 | |
| 62 | fn parse_resource_group() -> impl CharParser<ResourceDescriptorKind> { |
| 63 | let start = just('[').padded(); |
| 64 | let end = just(']').padded(); |
| 65 | |
| 66 | parse_individual_resources() |
| 67 | .try_map(|group, span| { |
| 68 | if group.is_empty() { |
| 69 | Err(ParseError::custom( |
| 70 | span, |
| 71 | "Each group has to contain at least a single element", |
| 72 | )) |
| 73 | } else { |
| 74 | Ok(group) |
| 75 | } |
| 76 | }) |
| 77 | .separated_by(just(',').padded()) |
| 78 | .at_least(1) |
| 79 | .delimited_by(start, end) |
| 80 | .try_map(|groups, span| { |
| 81 | ResourceDescriptorKind::groups(groups).map_err(|error| match error { |
| 82 | DescriptorError::ResourceListItemsNotUnique => { |
| 83 | ParseError::custom(span, "Group items have to be unique") |
| 84 | } |
| 85 | DescriptorError::EmptyGroups => { |
| 86 | ParseError::custom(span, "There has to be at least a single group") |
| 87 | } |
| 88 | }) |
| 89 | }) |
| 90 | } |
| 91 | |
| 92 | /// Parses a list resource. |
| 93 | /// The list must be non-empty and it has to contain uniaue values. |
no test coverage detected