diff options
Diffstat (limited to 'src/input.rs')
-rw-r--r-- | src/input.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/input.rs b/src/input.rs index b4b058e2..3a723631 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,6 +1,8 @@ +use std::convert::TryFrom; use std::ffi::{OsStr, OsString}; use std::fs::File; use std::io::{self, BufRead, BufReader, Read}; +use std::path::Path; use content_inspector::{self, ContentType}; @@ -192,6 +194,18 @@ impl<'a> Input<'a> { } } +impl TryFrom<&'_ Input<'_>> for clircle::Identifier { + type Error = (); + + fn try_from(input: &Input) -> std::result::Result<clircle::Identifier, ()> { + match input.kind { + InputKind::OrdinaryFile(ref path) => Self::try_from(Path::new(path)).map_err(|_| ()), + InputKind::StdIn => Self::try_from(clircle::Stdio::Stdin).map_err(|_| ()), + InputKind::CustomReader(_) => Err(()), + } + } +} + pub(crate) struct InputReader<'a> { inner: Box<dyn BufRead + 'a>, pub(crate) first_line: Vec<u8>, |