MCPcopy Create free account
hub / github.com/Moosync/Moosync / get_extension_state

Function get_extension_state

src-tauri/src/extensions/mod.rs:48–84  ·  view source on GitHub ↗
(app: AppHandle)

Source from the content-addressed store, hash-verified

46
47#[tracing::instrument(level = "debug", skip(app))]
48pub fn get_extension_state(app: AppHandle) -> Result<ExtensionHandler> {
49 let ext_path = app.path().app_data_dir().unwrap().join("extensions");
50 let tmp_dir = app.path().temp_dir().unwrap();
51 let cache_dir = app.path().cache_dir().unwrap();
52 let (ext_handler, mut ui_request_rx, ui_reply_tx) =
53 ExtensionHandler::new(ext_path, cache_dir, tmp_dir);
54
55 let app_clone = app.clone();
56 async_runtime::spawn(async move {
57 let app_handle = app.clone();
58 let reply_handler = ReplyHandler::new(app_handle);
59 loop {
60 tracing::trace!("Waiting for extension UI requests");
61 if let Some(resp) = ui_request_rx.recv().await {
62 if let Some(data) = resp.data {
63 tracing::debug!("Got main command {:?}", data);
64 match reply_handler.handle_request(data).await {
65 Ok(reply) => {
66 ui_reply_tx
67 .send(GenericExtensionHostRequest {
68 channel: resp.channel,
69 data: Some(reply),
70 })
71 .unwrap();
72 }
73 Err(e) => {
74 tracing::error!("Failed to handle extension command {:?}", e)
75 }
76 }
77 }
78 }
79 }
80 });
81 async_runtime::spawn(extension_runner_connected(app_clone));
82
83 Ok(ext_handler)
84}
85
86#[tracing::instrument(level = "debug", skip(app))]
87pub fn get_extension_handler(app: &AppHandle) -> State<'_, ExtensionHandler> {

Callers 1

runFunction · 0.85

Calls 4

cloneMethod · 0.80
handle_requestMethod · 0.80
sendMethod · 0.80

Tested by

no test coverage detected