1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// This file is part of yash, an extended POSIX shell.
// Copyright (C) 2021 WATANABE Yuki
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Methods about passing [source](crate::source) code to the
//! [parser](crate::parser).
//!
//! # Input sources
//!
//! The [`Input`] trait is the core abstraction for reading source code lines.
//! These types are leaf inputs that produce lines from a concrete source:
//!
//! - [`Memory`]: In-memory input from a pre-loaded string
//! - [`FdReader2`]: Reads from a file descriptor asynchronously
//!
//! # Input decorators
//!
//! Several decorators wrap an inner [`Input`] to add behavior:
//!
//! - [`Echo`]: Echoes each line read to stderr (for the `verbose` option)
//! - [`IgnoreEof`]: Retries on EOF when the `ignore-eof` option is on (simple
//! interactive use)
//! - [`Reporter`]: Reports job status changes before each prompt
//! - [`EofGuard`]: Combines suspended-jobs protection with `ignore-eof` retry;
//! prefer over [`IgnoreEof`] for the interactive read loop
//!
//! ## Configuration stored in `env.any`
//!
//! [`EofGuard`] reads its behavior configuration from
//! [`SuspendedJobsGuardConfig`] and [`IgnoreEofConfig`] stored in
//! [`Env::any`](crate::Env::any):
//!
//! - [`SuspendedJobsGuardConfig`]: enables the suspended-jobs protection in
//! [`EofGuard`] (and any other component that opts in). If absent, the
//! protection is disabled.
//! - [`IgnoreEofConfig`]: enables the `ignore-eof` retry behavior in
//! [`EofGuard`]. If absent, EOF is not retried even when the `ignore-eof`
//! option is on.
use DerefMut;
use Pin;
/// Parameter passed to the input function
///
/// The context is passed to the [input function](Input::next_line) so that it
/// can read the input in a context-dependent way.
/// Error returned by the [Input] function
pub type Error = Error;
/// Result of the [Input] function
pub type Result = Result;
/// Line-oriented source code reader
///
/// An `Input` implementor provides the parser with source code by reading from underlying source.
///
/// [`InputObject`] is an object-safe version of this trait.
/// Object-safe adapter for the [`Input`] trait
///
/// `InputObject` is an object-safe version of the [`Input`] trait. It allows
/// the trait to be used as a trait object, which is necessary for dynamic
/// dispatch.
///
/// The umbrella implementation is provided for all types that implement the
/// [`Input`] trait.
pub use Memory;
pub use FdReader2;
pub use Echo;
pub use IgnoreEof;
pub use Reporter;
pub use ;