MCPcopy Create free account
hub / github.com/archlinux/alpm / parse

Function parse

alpm-buildinfo/src/commands.rs:122–132  ·  view source on GitHub ↗

Parses a file according to a BUILDINFO schema. Returns a serializable BuildInfo if the file is valid, otherwise an error is returned. 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

(args: ValidateArgs)

Source from the content-addressed store, hash-verified

120///
121/// [`IsTerminal`]: https://doc.rust-lang.org/stable/std/io/trait.IsTerminal.html
122pub fn parse(args: ValidateArgs) -> Result<BuildInfo, Error> {
123 let build_info = if let Some(file) = &args.file {
124 BuildInfo::from_file_with_schema(file, args.schema)?
125 } else if !io::stdin().is_terminal() {
126 BuildInfo::from_stdin_with_schema(args.schema)?
127 } else {
128 Err(Error::NoInputFile)?
129 };
130
131 Ok(build_info)
132}
133
134/// Validate a file according to a BUILDINFO schema.
135///

Callers 3

mainFunction · 0.70
validateFunction · 0.70
formatFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected