feat: 支持 WatchDog

This commit is contained in:
mofeng-git
2026-07-16 20:07:33 +08:00
parent 213359b6c8
commit 50dd419e5a
17 changed files with 1127 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ mod computer_use;
mod hid;
mod otg_network;
mod stream;
mod watchdog;
mod web;
pub use atx::*;
@@ -18,6 +19,7 @@ pub use computer_use::*;
pub use hid::*;
pub use otg_network::*;
pub use stream::*;
pub use watchdog::*;
pub use web::*;
#[typeshare]
@@ -41,6 +43,7 @@ pub struct AppConfig {
pub vnc: VncConfig,
pub rtsp: RtspConfig,
pub redfish: RedfishConfig,
pub watchdog: WatchdogConfig,
}
impl AppConfig {
@@ -57,3 +60,18 @@ impl AppConfig {
self.enforce_invariants();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn missing_watchdog_config_defaults_to_disabled() {
let value = serde_json::to_value(AppConfig::default()).unwrap();
let mut object = value.as_object().unwrap().clone();
object.remove("watchdog");
let config: AppConfig = serde_json::from_value(object.into()).unwrap();
assert!(!config.watchdog.enabled);
}
}

View File

@@ -0,0 +1,9 @@
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[typeshare]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct WatchdogConfig {
pub enabled: bool,
}