Mountain/IPC/WindServiceHandlers/Cocoon/
Notify.rs1#![allow(unused_variables, dead_code, unused_imports)]
2
3use serde_json::Value;
10
11pub async fn Fn(Arguments:Vec<Value>) -> Result<Value, String> {
12 crate::dev_log!("ipc", "cocoon:notify method={:?}", Arguments.first());
13
14 let MethodOpt = Arguments.first().and_then(|V| V.as_str()).map(|S| S.to_string());
15
16 match MethodOpt {
17 None => Err("cocoon:notify requires method string in slot 0".to_string()),
18
19 Some(Method) => {
20 let Payload = Arguments.get(1).cloned().unwrap_or(Value::Null);
21
22 if let Err(Error) =
23 crate::Vine::Client::SendNotification::Fn("cocoon-main".to_string(), Method.clone(), Payload).await
24 {
25 crate::dev_log!("ipc", "warn: [cocoon:notify] {} failed: {:?}", Method, Error);
26 }
27
28 Ok(Value::Null)
29 },
30 }
31}