Skip to main content

Mountain/IPC/WindServiceHandlers/Cocoon/
Notify.rs

1#![allow(unused_variables, dead_code, unused_imports)]
2
3//! Wire method: `cocoon:notify`.
4//! Fire-and-forget renderer→Cocoon notification bridge for one-way wire
5//! methods (`webview.message`, `webview.dispose`, `webview.viewState`, etc.)
6//! where the extension doesn't reply. Returns null immediately; the
7//! notification dispatches asynchronously avoiding the 30 s request timeout.
8
9use 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}