Zhi Dou | e8a4ee7 | 2023-12-18 20:32:55 +0000 | [diff] [blame] | 1 | //! codegenerated rust flag lib |
| 2 | |
| 3 | /// flag provider |
| 4 | pub struct FlagProvider; |
| 5 | |
| 6 | lazy_static::lazy_static! \{ |
| 7 | {{ for flag in template_flags }} |
| 8 | /// flag value cache for {flag.name} |
| 9 | static ref CACHED_{flag.name}: bool = flags_rust::GetServerConfigurableFlag( |
| 10 | "aconfig_flags.{flag.device_config_namespace}", |
| 11 | "{flag.device_config_flag}", |
| 12 | "false") == "true"; |
| 13 | {{ endfor }} |
| 14 | } |
| 15 | |
| 16 | impl FlagProvider \{ |
| 17 | |
| 18 | {{ for flag in template_flags }} |
| 19 | /// query flag {flag.name} |
| 20 | pub fn {flag.name}(&self) -> bool \{ |
| 21 | *CACHED_{flag.name} |
| 22 | } |
| 23 | {{ endfor }} |
| 24 | |
| 25 | } |
| 26 | |
| 27 | /// flag provider |
| 28 | pub static PROVIDER: FlagProvider = FlagProvider; |
| 29 | |
| 30 | {{ for flag in template_flags }} |
| 31 | /// query flag {flag.name} |
| 32 | #[inline(always)] |
| 33 | pub fn {flag.name}() -> bool \{ |
| 34 | PROVIDER.{flag.name}() |
| 35 | } |
| 36 | {{ endfor }} |