From 01db294700a594b9b004855097b3bcfee9946d61 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 9 Nov 2019 13:29:20 +0100 Subject: Add Runtime::input_is_pipe() We need this because we might want to check whether we can get the STDIN handle from the runtime or not. In some (rare) cases, the runtime "thinks" that STDIN is a stream of IDs, but it is not. So the client can check whether stdin is a pipe (thus, whether Runtime thinks that there's a stream of IDs) and easily work around that by taking ::std::io::stdin() itself. Signed-off-by: Matthias Beyer --- lib/core/libimagrt/src/runtime.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/core/libimagrt/src/runtime.rs b/lib/core/libimagrt/src/runtime.rs index 89587487..d8997a8b 100644 --- a/lib/core/libimagrt/src/runtime.rs +++ b/lib/core/libimagrt/src/runtime.rs @@ -336,10 +336,6 @@ impl<'a> Runtime<'a> { &self.cli_matches } - pub fn ids_from_stdin(&self) -> bool { - self.has_input_pipe - } - pub fn ids(&self) -> Result>> { use std::io::Read; @@ -410,6 +406,16 @@ impl<'a> Runtime<'a> { self.has_output_pipe } + pub fn input_is_pipe(&self) -> bool { + self.has_input_pipe + } + + /// Alias for Runtime::input_is_pipe() + pub fn ids_from_stdin(&self) -> bool { + self.input_is_pipe() + } + + /// Check whether the runtime ignores touched ids /// /// "Ignoring" in this context means whether the runtime prints them or not. -- cgit v1.2.3