pub enum Feature {
DpiAware(DpiMode),
ControlsV6,
}
impl Feature {
pub fn xml(&self) -> String {
match self {
Self::DpiAware(mode) => mode.xml(),
Self::ControlsV6 => include_str!("../../../manifest/controlsv6.xml").to_string(),
}
}
}
#[derive(Debug)]
pub enum DpiMode {
Unaware,
System,
PerMonitor,
PerMonitorV2,
}
impl DpiMode {
pub fn xml(&self) -> String {
let (aware, awareness) = match self {
Self::Unaware => ("false", "unaware"),
Self::System => ("true", "system"),
Self::PerMonitor => ("true/pm", "PerMonitor"),
Self::PerMonitorV2 => ("true", "PerMonitorV2"), };
let mut xml = String::from(include_str!("../../../manifest/dpiaware.xml"));
replace(&mut xml, "{aware}", aware);
replace(&mut xml, "{awareness}", awareness);
xml
}
}
fn replace(string: &mut String, key: &str, value: &str) {
let index = string.find(key).unwrap();
string.replace_range(index..index + key.len(), value);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn dpimode() {
assert!(!DpiMode::System.xml().is_empty());
}
}