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

Function parse_resource_list

crates/hyperqueue/src/worker/parser.rs:97–113  ·  view source on GitHub ↗

Parses a list resource. The list must be non-empty and it has to contain uniaue values. The values inside the list can be either numbers or strings. Strings can be put into quotes if you need to include a comma inside of them. Example: `[1, 2]`, `[abc, def]`, `["abc","a,b",c]`.

()

Source from the content-addressed store, hash-verified

95/// Strings can be put into quotes if you need to include a comma inside of them.
96/// Example: `[1, 2]`, `[abc, def]`, `["abc","a,b",c]`.
97fn parse_resource_list() -> impl CharParser<ResourceDescriptorKind> {
98 parse_individual_resources().try_map(|indices, span| {
99 if indices.is_empty() {
100 Err(ParseError::custom(
101 span,
102 "List has to contain at least a single element",
103 ))
104 } else {
105 ResourceDescriptorKind::list(indices).map_err(|error| match error {
106 DescriptorError::ResourceListItemsNotUnique => {
107 ParseError::custom(span, "List items have to be unique")
108 }
109 error => ParseError::custom(span, error.to_string()),
110 })
111 }
112 })
113}
114
115/// Parses a range resource.
116/// The start of the range must be smaller or equal to the end.

Callers 1

parse_resource_kindFunction · 0.85

Calls 3

to_stringMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected