Refactor: introduce 2 associated functions to PipelineData (#16233)

# Description
As title: this pr is try to introduce 2 functions to `PipelineData`:
1. PipelineData::list_stream --> create a PipelineData::ListStream
2. PipelineData::byte_stream -> create a PipelineData::ByteStream
And use these functions everywhere.

### Reason behind this change
I tried to implement `pipefail` feature, but this would required to
change `PipelineData` from enum to struct. So use these functions can
reduce diff if I finally change to struct. [Discord message
here](https://discord.com/channels/601130461678272522/615962413203718156/1396999539000479784)
is my plan.

# User-Facing Changes
NaN

# Tests + Formatting
NaN

# After Submitting
NaN
This commit is contained in:
Wind
2025-08-02 09:30:30 +08:00
committed by GitHub
parent ee5b5bd39e
commit eb8d2d3206
126 changed files with 299 additions and 304 deletions

View File

@ -48,7 +48,7 @@ impl PluginCommand for CollectBytes {
call: &EvaluatedCall,
input: PipelineData,
) -> Result<PipelineData, LabeledError> {
Ok(PipelineData::ByteStream(
Ok(PipelineData::byte_stream(
ByteStream::from_result_iter(
input.into_iter().map(Value::coerce_into_binary),
call.head,

View File

@ -45,6 +45,6 @@ impl PluginCommand for Ctrlc {
eprintln!("interrupt status: {:?}", engine.signals().interrupted());
eprintln!("peace.");
Ok(PipelineData::Empty)
Ok(PipelineData::empty())
}
}

View File

@ -53,7 +53,7 @@ impl PluginCommand for ForEach {
let result = engine.eval_closure(&closure, vec![value.clone()], Some(value))?;
eprintln!("{}", result.to_expanded_string(", ", &config));
}
Ok(PipelineData::Empty)
Ok(PipelineData::empty())
}
}

View File

@ -57,7 +57,7 @@ impl PluginCommand for Sum {
.with_label("can't be used here", call.head));
}
}
Ok(PipelineData::Value(acc.to_value(call.head), None))
Ok(PipelineData::value(acc.to_value(call.head), None))
}
}