mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Rename IoStream
to OutDest
(#12433)
# Description I spent a while trying to come up with a good name for what is currently `IoStream`. Looking back, this name is not the best, because it: 1. Implies that it is a stream, when it all it really does is specify the output destination for a stream/pipeline. 2. Implies that it handles input and output, when it really only handles output. So, this PR renames `IoStream` to `OutDest` instead, which should be more clear.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
use super::Pipeline;
|
||||
use crate::{engine::EngineState, IoStream, Signature, Span, Type, VarId};
|
||||
use crate::{engine::EngineState, OutDest, Signature, Span, Type, VarId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@ -20,12 +20,12 @@ impl Block {
|
||||
self.pipelines.is_empty()
|
||||
}
|
||||
|
||||
pub fn stdio_redirect(
|
||||
pub fn pipe_redirection(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
) -> (Option<IoStream>, Option<IoStream>) {
|
||||
) -> (Option<OutDest>, Option<OutDest>) {
|
||||
if let Some(first) = self.pipelines.first() {
|
||||
first.stdio_redirect(engine_state)
|
||||
first.pipe_redirection(engine_state)
|
||||
} else {
|
||||
(None, None)
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ use super::{
|
||||
RangeOperator,
|
||||
};
|
||||
use crate::{
|
||||
ast::ImportPattern, ast::Unit, engine::EngineState, BlockId, IoStream, Signature, Span,
|
||||
Spanned, VarId,
|
||||
ast::ImportPattern, ast::Unit, engine::EngineState, BlockId, OutDest, Signature, Span, Spanned,
|
||||
VarId,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@ -56,19 +56,19 @@ pub enum Expr {
|
||||
}
|
||||
|
||||
impl Expr {
|
||||
pub fn stdio_redirect(
|
||||
pub fn pipe_redirection(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
) -> (Option<IoStream>, Option<IoStream>) {
|
||||
) -> (Option<OutDest>, Option<OutDest>) {
|
||||
// Usages of `$in` will be wrapped by a `collect` call by the parser,
|
||||
// so we do not have to worry about that when considering
|
||||
// which of the expressions below may consume pipeline output.
|
||||
match self {
|
||||
Expr::Call(call) => engine_state.get_decl(call.decl_id).stdio_redirect(),
|
||||
Expr::Call(call) => engine_state.get_decl(call.decl_id).pipe_redirection(),
|
||||
Expr::Subexpression(block_id) | Expr::Block(block_id) => engine_state
|
||||
.get_block(*block_id)
|
||||
.stdio_redirect(engine_state),
|
||||
Expr::FullCellPath(cell_path) => cell_path.head.expr.stdio_redirect(engine_state),
|
||||
.pipe_redirection(engine_state),
|
||||
Expr::FullCellPath(cell_path) => cell_path.head.expr.pipe_redirection(engine_state),
|
||||
Expr::Bool(_)
|
||||
| Expr::Int(_)
|
||||
| Expr::Float(_)
|
||||
@ -89,7 +89,7 @@ impl Expr {
|
||||
| Expr::Nothing => {
|
||||
// These expressions do not use the output of the pipeline in any meaningful way,
|
||||
// so we can discard the previous output by redirecting it to `Null`.
|
||||
(Some(IoStream::Null), None)
|
||||
(Some(OutDest::Null), None)
|
||||
}
|
||||
Expr::VarDecl(_)
|
||||
| Expr::Operator(_)
|
||||
@ -103,7 +103,7 @@ impl Expr {
|
||||
| Expr::Garbage => {
|
||||
// These should be impossible to pipe to,
|
||||
// but even it is, the pipeline output is not used in any way.
|
||||
(Some(IoStream::Null), None)
|
||||
(Some(OutDest::Null), None)
|
||||
}
|
||||
Expr::RowCondition(_) | Expr::MatchBlock(_) => {
|
||||
// These should be impossible to pipe to,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
ast::Expression,
|
||||
engine::{EngineState, StateWorkingSet},
|
||||
IoStream, Span,
|
||||
OutDest, Span,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Display;
|
||||
@ -118,11 +118,11 @@ impl PipelineElement {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stdio_redirect(
|
||||
pub fn pipe_redirection(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
) -> (Option<IoStream>, Option<IoStream>) {
|
||||
self.expr.expr.stdio_redirect(engine_state)
|
||||
) -> (Option<OutDest>, Option<OutDest>) {
|
||||
self.expr.expr.pipe_redirection(engine_state)
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,12 +164,12 @@ impl Pipeline {
|
||||
self.elements.is_empty()
|
||||
}
|
||||
|
||||
pub fn stdio_redirect(
|
||||
pub fn pipe_redirection(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
) -> (Option<IoStream>, Option<IoStream>) {
|
||||
) -> (Option<OutDest>, Option<OutDest>) {
|
||||
if let Some(first) = self.elements.first() {
|
||||
first.stdio_redirect(engine_state)
|
||||
first.pipe_redirection(engine_state)
|
||||
} else {
|
||||
(None, None)
|
||||
}
|
||||
|
Reference in New Issue
Block a user