Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Cocoon/
ExtensionHostMessage.rs

1#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2
3//! Wire method: `cocoon:extensionHostMessage`.
4//! Relays binary extension-host protocol messages from Wind/Sky to Cocoon via
5//! gRPC GenericNotification. Fire-and-forget - the extension host protocol is
6//! fully async; Mountain does not await a reply.
7
8use serde_json::Value;
9use tauri::AppHandle;
10
11pub async fn CocoonExtensionHostMessage(_ApplicationHandle:AppHandle, Arguments:Vec<Value>) -> Result<Value, String> {
12	let ByteCount = Arguments
13		.first()
14		.map(|P| P.get("data").and_then(|D| D.as_array()).map(|A| A.len()).unwrap_or(0))
15		.unwrap_or(0);
16	crate::dev_log!("exthost", "cocoon:extensionHostMessage bytes={}", ByteCount);
17
18	let Payload = Arguments.first().cloned().unwrap_or(Value::Null);
19	tokio::spawn(async move {
20		if let Err(Error) = crate::Vine::Client::SendNotification::Fn(
21			"cocoon-main".to_string(),
22			"extensionHostMessage".to_string(),
23			Payload,
24		)
25		.await
26		{
27			crate::dev_log!("exthost", "cocoon:extensionHostMessage forward failed: {}", Error);
28		}
29	});
30	Ok(Value::Null)
31}