pub struct IgnoreEof<'a, 'b, S, T> { /* private fields */ }Expand description
Input decorator that ignores EOF on a terminal
This is a decorator of Input that adds the behavior of the
ignore-eof shell option.
The decorator is effective only when all of the following conditions are met:
- The shell is interactive, that is, the
Interactiveoption is enabled. - The
ignore-eofoption is enabled. - The input is a terminal.
The decorator reads from the inner input and usually returns the result as is. However, if the result is an empty string and the above conditions are met, the decorator will re-read the input until a non-empty string is obtained, an error occurs, or this process is repeated 20 times.
Implementations§
Source§impl<'a, 'b, S, T> IgnoreEof<'a, 'b, S, T>
impl<'a, 'b, S, T> IgnoreEof<'a, 'b, S, T>
Sourcepub fn new(
inner: T,
fd: Fd,
env: &'a RefCell<&'b mut Env<S>>,
message: String,
) -> Self
pub fn new( inner: T, fd: Fd, env: &'a RefCell<&'b mut Env<S>>, message: String, ) -> Self
Creates a new IgnoreEof decorator.
The first argument is the inner Input that performs the actual input
operation. The second argument is the file descriptor to be checked if
it is a terminal. The third argument is the shell environment that
contains the shell option state and the system interface to interact
with the system. It is wrapped in a RefCell so that it can be shared
with other decorators and the parser. The fourth argument is the text to
be displayed when EOF is ignored.
The second argument fd should match the file descriptor that the inner
input reads from. If the inner input reads from a different file
descriptor, the IgnoreEof decorator may not detect the terminal
correctly.
Trait Implementations§
Auto Trait Implementations§
impl<'a, 'b, S, T> Freeze for IgnoreEof<'a, 'b, S, T>where
T: Freeze,
impl<'a, 'b, S, T> !RefUnwindSafe for IgnoreEof<'a, 'b, S, T>
impl<'a, 'b, S, T> !Send for IgnoreEof<'a, 'b, S, T>
impl<'a, 'b, S, T> !Sync for IgnoreEof<'a, 'b, S, T>
impl<'a, 'b, S, T> Unpin for IgnoreEof<'a, 'b, S, T>where
T: Unpin,
impl<'a, 'b, S, T> !UnwindSafe for IgnoreEof<'a, 'b, S, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InputObject for Twhere
T: Input,
impl<T> InputObject for Twhere
T: Input,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more