pub fn select_result_plan(command: &str) -> Result<ResultPlan, String>Expand description
Select one compatible typed plan for conservative post-result reduction.
ยงErrors
Returns an error when shell syntax is ambiguous, guarded, unsupported, or mixes reducer families. Callers fail open on every error.
Examples found in repository?
examples/shell_parser_fuzz.rs (line 14)
5fn main() -> Result<(), String> {
6 let mut bytes = Vec::new();
7 io::stdin()
8 .take(MAX_FUZZ_INPUT_BYTES)
9 .read_to_end(&mut bytes)
10 .map_err(|error| format!("could not read fuzz input: {error}"))?;
11 let source = String::from_utf8_lossy(&bytes).into_owned();
12 let original = source.clone();
13 let _ = yarp_cli::shell::inspect_syntax(&source);
14 let _ = yarp_cli::rewrite::select_result_plan(&source);
15 let _ = yarp_cli::rewrite::rewrite(&source);
16 if source != original {
17 return Err("shell classification changed its input".to_owned());
18 }
19 Ok(())
20}More examples
examples/indexed_output_benchmark.rs (lines 108-110)
100fn benchmark_parser(
101 source: &str,
102 warmup: usize,
103 sample_count: usize,
104) -> Result<Vec<Duration>, String> {
105 let mut samples = Vec::with_capacity(sample_count);
106 for iteration in 0..warmup.saturating_add(sample_count) {
107 let started = Instant::now();
108 std::hint::black_box(yarp_cli::rewrite::select_result_plan(std::hint::black_box(
109 source,
110 )))
111 .map_err(|error| format!("parser benchmark command was rejected: {error}"))?;
112 let elapsed = started.elapsed();
113 if iteration >= warmup {
114 samples.push(elapsed);
115 }
116 }
117 Ok(samples)
118}