bootmgr_rs_core/
features.rs

1//! Stubs for features that are disabled
2
3/// Creates an optional config.
4///
5/// For a config parser that implements `ConfigParser`, one should add the parser to this features file
6/// in order to allow it to be disabled or enabled through the features.
7///
8/// This macro takes three parameters. The first of these is the feature as a string literal. This means
9/// that whatever your feature is called (such as bls), it should be wrapped in double quotes as though
10/// it were a string literal, like "bls".
11/// The second is the feature as an identifier, and should be the name of the configuration parser module.
12/// This should be the same as the previous parameter, without double quotes as it is not a string literal.
13/// The third is the name of the config struct that implements `ConfigParser`. This can be named something like
14/// `BlsConfig`.
15/// The final macro invocation should look something like `optional_config!("bls", bls, BlsConfig)`.
16macro_rules! optional_config {
17    ($feature:literal, $name:ident, $config:ident) => {
18        /// The parser for $config
19        #[cfg(feature = $feature)]
20        pub(crate) mod $name {
21            pub use crate::config::parsers::$name::$config;
22        }
23
24        /// The disabled parser for $config
25        #[cfg(not(feature = $feature))]
26        pub(crate) mod $name {
27            use crate::{
28                config::{Config, parsers::ConfigParser},
29                system::fs::UefiFileSystem,
30            };
31            use alloc::vec::Vec;
32
33            pub(crate) struct $config;
34
35            impl ConfigParser for $config {
36                fn parse_configs(
37                    _fs: &mut UefiFileSystem,
38                    _handle: Handle,
39                    _configs: &mut Vec<Config>,
40                ) {
41                }
42            }
43        }
44    };
45}
46
47optional_config!("bls", bls, BlsConfig);
48optional_config!("fallback", fallback, FallbackConfig);
49optional_config!("osx", osx, OsxConfig);
50optional_config!("shell", shell, ShellConfig);
51optional_config!("uki", uki, UkiConfig);
52optional_config!("windows", windows, WinConfig);