-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from posit-dev/feature/frontend-comm-spec
Switch to new frontend comm spec
- Loading branch information
Showing
16 changed files
with
212 additions
and
195 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,105 @@ | ||
/* | ||
* frontend_comm.rs | ||
* | ||
* Copyright (C) 2023 Posit Software, PBC. All rights reserved. | ||
* | ||
*/ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2023 Posit Software, PBC. All rights reserved. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
// | ||
// AUTO-GENERATED from frontend.json; do not edit. | ||
// | ||
|
||
use serde::Deserialize; | ||
use serde::Serialize; | ||
use serde_json::Value; | ||
|
||
use crate::comm::base_comm::JsonRpcErrorCode; | ||
use crate::wire::client_event::ClientEvent; | ||
/// Items in Params | ||
pub type Params = serde_json::Value; | ||
|
||
/// The method result | ||
pub type CallMethodResult = serde_json::Value; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(tag = "msg_type", rename_all = "snake_case")] | ||
pub enum FrontendMessage { | ||
Event(ClientEvent), | ||
RpcRequest(FrontendRpcRequest), | ||
RpcResultResponse(FrontendRpcResult), | ||
RpcResultError(FrontendRpcError), | ||
/// Parameters for the CallMethod method. | ||
#[derive(Debug, Serialize, Deserialize, PartialEq)] | ||
pub struct CallMethodParams { | ||
/// The method to call inside the interpreter | ||
pub method: String, | ||
|
||
/// The parameters for `method` | ||
pub params: Vec<Params>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct FrontendRpcRequest { | ||
pub method: String, | ||
pub params: Vec<Value>, | ||
/// Parameters for the Busy method. | ||
#[derive(Debug, Serialize, Deserialize, PartialEq)] | ||
pub struct BusyParams { | ||
/// Whether the backend is busy | ||
pub busy: bool, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct FrontendRpcResult { | ||
pub id: String, | ||
pub result: Value, | ||
/// Parameters for the ShowMessage method. | ||
#[derive(Debug, Serialize, Deserialize, PartialEq)] | ||
pub struct ShowMessageParams { | ||
/// The message to show to the user. | ||
pub message: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct FrontendRpcErrorData { | ||
pub message: String, | ||
pub code: JsonRpcErrorCode, | ||
/// Parameters for the PromptState method. | ||
#[derive(Debug, Serialize, Deserialize, PartialEq)] | ||
pub struct PromptStateParams { | ||
/// Prompt for primary input. | ||
pub input_prompt: String, | ||
|
||
/// Prompt for incomplete input. | ||
pub continuation_prompt: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(tag = "msg_type", rename_all = "snake_case")] | ||
pub struct FrontendRpcError { | ||
pub id: String, | ||
pub error: FrontendRpcErrorData, | ||
/// Parameters for the WorkingDirectory method. | ||
#[derive(Debug, Serialize, Deserialize, PartialEq)] | ||
pub struct WorkingDirectoryParams { | ||
/// The new working directory | ||
pub directory: String, | ||
} | ||
|
||
/** | ||
* RPC request types for the frontend comm | ||
*/ | ||
#[derive(Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(tag = "method", content = "params")] | ||
pub enum FrontendRpcRequest { | ||
/// Run a method in the interpreter and return the result to the frontend | ||
/// | ||
/// Unlike other RPC methods, `call_method` calls into methods implemented | ||
/// in the interpreter and returns the result back to the frontend using | ||
/// an implementation-defined serialization scheme. | ||
#[serde(rename = "call_method")] | ||
CallMethod(CallMethodParams), | ||
|
||
} | ||
|
||
/** | ||
* RPC Reply types for the frontend comm | ||
*/ | ||
#[derive(Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(tag = "method", content = "result")] | ||
pub enum FrontendRpcReply { | ||
/// The method result | ||
CallMethodReply(CallMethodResult), | ||
|
||
} | ||
|
||
/** | ||
* Front-end events for the frontend comm | ||
*/ | ||
#[derive(Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(tag = "method", content = "params")] | ||
pub enum FrontendEvent { | ||
#[serde(rename = "busy")] | ||
Busy(BusyParams), | ||
|
||
#[serde(rename = "show_message")] | ||
ShowMessage(ShowMessageParams), | ||
|
||
#[serde(rename = "prompt_state")] | ||
PromptState(PromptStateParams), | ||
|
||
#[serde(rename = "working_directory")] | ||
WorkingDirectory(WorkingDirectoryParams), | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.