MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / parse_resource_group

Function parse_resource_group

crates/hyperqueue/src/worker/parser.rs:62–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60}
61
62fn 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.

Callers 1

parse_resource_kindFunction · 0.85

Calls 3

groupsFunction · 0.50
is_emptyMethod · 0.45

Tested by

no test coverage detected