()
| 10 | use crate::worker::parser::{is_valid_resource_char, is_valid_starting_resource_char}; |
| 11 | |
| 12 | fn p_allocation_request() -> impl CharParser<AllocationRequest> { |
| 13 | parse_exact_string("all") |
| 14 | .map(|_| AllocationRequest::All) |
| 15 | .or(parse_resource_amount() |
| 16 | .padded() |
| 17 | .then( |
| 18 | choice(( |
| 19 | just("compact!"), |
| 20 | just("compact"), |
| 21 | just("tight!"), |
| 22 | just("tight"), |
| 23 | just("scatter"), |
| 24 | )) |
| 25 | .or_not(), |
| 26 | ) |
| 27 | .try_map(|(amount, policy), span| { |
| 28 | let alloc = match policy { |
| 29 | None | Some("compact") => AllocationRequest::Compact(amount), |
| 30 | Some("compact!") => AllocationRequest::ForceCompact(amount), |
| 31 | Some("tight") => AllocationRequest::Tight(amount), |
| 32 | Some("tight!") => AllocationRequest::ForceTight(amount), |
| 33 | Some("scatter") => AllocationRequest::Scatter(amount), |
| 34 | _ => unreachable!(), |
| 35 | }; |
| 36 | alloc |
| 37 | .validate() |
| 38 | .map_err(|e| ParseError::custom(span, e.to_string()))?; |
| 39 | Ok(alloc) |
| 40 | })) |
| 41 | } |
| 42 | |
| 43 | fn p_resource_identifier() -> impl CharParser<String> { |
| 44 | filter(|&c| is_valid_starting_resource_char(c)) |
no test coverage detected