(event: &str, payload: &str)
| 206 | } |
| 207 | |
| 208 | pub async fn notify_host(event: &str, payload: &str) -> Result<()> { |
| 209 | let local_config: SysConfig = serde_json::from_str(&fs::read_to_string(format!( |
| 210 | "{HOST_SHARED_DIR}/{SYS_CONFIG}" |
| 211 | ))?)?; |
| 212 | let Some(host_api_url) = local_config.host_api_url else { |
| 213 | anyhow::bail!("host_api_url not configured"); |
| 214 | }; |
| 215 | let nc = host_api::client::new_client(host_api_url); |
| 216 | nc.notify(Notification { |
| 217 | event: event.to_string(), |
| 218 | payload: payload.to_string(), |
| 219 | }) |
| 220 | .await?; |
| 221 | Ok(()) |
| 222 | } |
| 223 | |
| 224 | fn perr<T, E: Debug>(result: Result<T, E>) { |
| 225 | if let Err(e) = &result { |
no test coverage detected