Parses and interprets a SRCINFO file from a path or stdin. ## Note If a command is piped to this process, the input is read from stdin. See [`IsTerminal`] for more information about how terminal detection works. [`IsTerminal`]: https://doc.rust-lang.org/stable/std/io/trait.IsTerminal.html # Errors Returns an error if the input can not be parsed and validated, or if the output can not be forma
(
file: Option<&PathBuf>,
schema: Option<SourceInfoSchema>,
)
| 162 | /// Furthermore, returns an error array with potentially un/-recoverable (linting-)errors, which |
| 163 | /// needs to be explicitly handled by the caller. |
| 164 | pub fn parse( |
| 165 | file: Option<&PathBuf>, |
| 166 | schema: Option<SourceInfoSchema>, |
| 167 | ) -> Result<SourceInfo, Error> { |
| 168 | let source_info = if let Some(file) = file { |
| 169 | SourceInfo::from_file_with_schema(file, schema)? |
| 170 | } else if !io::stdin().is_terminal() { |
| 171 | SourceInfo::from_stdin_with_schema(schema)? |
| 172 | } else { |
| 173 | Err(Error::NoInputFile)? |
| 174 | }; |
| 175 | |
| 176 | Ok(source_info) |
| 177 | } |
no outgoing calls
no test coverage detected