Skip to main content

Mountain/RPC/CocoonService/Output/
CreateOutputChannel.rs

1//! Create a new output channel and notify Sky over `sky://output/create`.
2
3use serde_json::json;
4use tauri::Emitter;
5use tonic::{Response, Status};
6use ::Vine::Generated::{CreateOutputChannelRequest, CreateOutputChannelResponse};
7
8use crate::{RPC::CocoonService::CocoonServiceImpl, dev_log};
9
10pub async fn Fn(
11	Service:&CocoonServiceImpl,
12
13	Request:CreateOutputChannelRequest,
14) -> Result<Response<CreateOutputChannelResponse>, Status> {
15	dev_log!("cocoon", "[CocoonService] create_output_channel: '{}'", Request.name);
16
17	// Sky's InstallEditorAndOutput.ts destructures { id, name }.
18	// The old `{ channel }` key made both fields undefined, keying the
19	// output channel on the string "undefined" in Sky's map.
20	let _ = Service
21		.environment
22		.ApplicationHandle
23		.emit("sky://output/create", json!({ "id": Request.name, "name": Request.name }));
24
25	Ok(Response::new(CreateOutputChannelResponse { channel_id:Request.name.clone() }))
26}