Debian Codegraph @

rust/src/lib.rs

raw
1 #![warn(missing_docs)]
2 // SPDX-FileCopyrightText: Peter Pentchev <[email protected]>
3 // SPDX-License-Identifier: BSD-2-Clause
4 //! Query a program for supported features.
5 //!
6 //! The [`obtain::obtain_features`]
7 //! function queries a program for the features that it supports
8 //! via various methods (e.g. running it with the `--features`
9 //! command-line option) and allows other programs to check for
10 //! the presence and, possibly, versions of specific features.
11 //!
12 //! ```rust
13 //! # use anyhow::{bail, Result};
14 //!
15 //! use feature_check::defs::{Config, Obtained};
16 //! use feature_check::obtain;
17 //!
18 //! # fn main() -> Result<()> {
19 //! match obtain::obtain_features(&Config::default()
20 //! .with_program("confget".to_string()))? {
21 //! Obtained::NotSupported => eprintln!("Feature query not supported"),
22 //! Obtained::Failed(err) => eprintln!("Could not query for features: {err}"),
23 //! Obtained::Features(res) => {
24 //! let mut features: Vec<&String> = res.keys().collect();
25 //! features.sort_unstable();
26 //! for name in &features {
27 //! println!("{name}");
28 //! }
29 //! },
30 //! other => bail!("Unexpected obtain_features() result: {:?}", other)
31 //! }
32 //! # Ok(())
33 //! # }
34 //! ```
35
36 #![doc(html_root_url = "https://docs.rs/feature-check/2.3.2")]
37
38 pub mod defs;
39 pub mod expr;
40 pub mod obtain;
41 pub mod version;