Skip to main content

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