Created
December 13, 2021 07:41
-
-
Save apowers313/15bc153b0facec38331b7876eabe3457 to your computer and use it in GitHub Desktop.
Jupyter Messages in Rust
This file contains hidden or 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
// /* ***************** | |
// * SHELL MESSAGES | |
// * *****************/ | |
// Shell Request Message Types | |
// "execute_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#execute | |
// "inspect_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection | |
// "complete_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion | |
// "history_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#history | |
// "is_complete_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness | |
// "comm_info_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info | |
// "kernel_info_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info | |
// Shell Reply Message Types | |
// "execute_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-results | |
// "inspect_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection | |
// "complete_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion | |
// "history_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#history | |
// "is_complete_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness | |
// "comm_info_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info | |
// "kernel_info_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#execute | |
struct ExecuteRequestContent { | |
code: String, | |
silent: bool, | |
store_history: bool, | |
user_expressions: Value, | |
allow_stdin: bool, | |
stop_on_error: bool, | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-results | |
struct ExecuteReplyContent { | |
status: String, | |
execution_count: u32, | |
payload: Option<Vec<String>>, | |
user_expressions: Option<Value>, | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection | |
struct InspectRequestContent { | |
code: String, | |
cursor_pos: u32, | |
detail_level: u8, // 0 = Low, 1 = High | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection | |
struct InspectReplyContent { | |
status: String, | |
found: bool, | |
data: Option<Value>, | |
metadata: Option<Value>, | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion | |
struct CompleteRequestContent { | |
code: String, | |
cursor_pos: u32, | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion | |
struct CompleteReplyContent { | |
status: String, | |
matches: Option<Value>, | |
cursor_start: u32, | |
cursor_end: u32, | |
metadata: Option<Value> | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#history | |
struct HistoryRequestContent { | |
output: bool, | |
raw: bool, | |
hist_access_type: String, // "range" | "tail" | "search" | |
session: u32, | |
start: u32, | |
stop: u32, | |
n: u32, | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#history | |
struct HistoryReplyContent { | |
status: String, | |
history: Option<Value> | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness | |
struct CodeCompleteRequestContent { | |
code: String | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness | |
struct CodeCompleteReplyContent { | |
status: String, // "complete" | "incomplete" | "invalid" | "unknown" | |
indent: String, | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info | |
struct CommInfoRequestContent { | |
target_name: String | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-info | |
struct CommInfoReplyContent { | |
status: String, | |
comms: Option<Value>, | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info | |
// struct KernelInfoRequest {} // empty | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info | |
struct KernelInfoReply { | |
status: String, | |
protocol_version: String, | |
implementation: String, | |
implementation_version: String, | |
language_info: KernelLanguageInfo, | |
banner: String, | |
debugger: bool, | |
help_links: Vec<KernelHelpLink> | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info | |
struct KernelLanguageInfo { | |
name: String, | |
version: String, | |
mimetype: String, | |
file_extension: String, | |
pygments_lexer: String, | |
codemirror_mode: Option<Value>, | |
nbconvert_exporter: String | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info | |
struct KernelHelpLink { | |
text: String, | |
url: String, | |
} | |
/* ***************** | |
* CONTROL MESSAGES | |
* *****************/ | |
// Control Request Message Types | |
// "shutdown_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-shutdown | |
// "interrupt_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-interrupt | |
// "debug_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#debug-request | |
// Control Reply Message Types | |
// "shutdown_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-shutdown | |
// "interrupt_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-interrupt | |
// "debug_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#debug-request | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-shutdown | |
struct ShutdownRequestContent { | |
restart: bool | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-shutdown | |
struct ShutdownReplyContent { | |
status: String, | |
restart: bool | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-interrupt | |
// struct InterruptRequestContent {} // empty | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-interrupt | |
struct InterruptReplyContent { | |
status: String | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#debug-request | |
// struct DebugRequestContent {} // See Debug Adapter Protocol (DAP) 1.39 or later | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#debug-request | |
// struct DebugReplyContent {} // See Debug Adapter Protocol (DAP) 1.39 or later | |
/* ***************** | |
* IOPUB MESSAGES | |
* *****************/ | |
// Io Pub Message Types | |
// "stream" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#streams-stdout-stderr-etc | |
// "display_data" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#display-data | |
// "update_display_data" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#update-display-data | |
// "execute_input" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-inputs | |
// "execute_result" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#id6 | |
// "error" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-errors | |
// "status" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-status | |
// "clear_output" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#clear-output | |
// "debug_event" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#debug-event | |
// "comm_open" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#opening-a-comm | |
// "comm_msg" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-messages | |
// "comm_close" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#tearing-down-comms | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#request-reply | |
struct ErrorStatusContent { | |
status: String, // "error" | |
ename: String, | |
evalue: String, | |
traceback: Vec<String>, | |
execution_count: Option<u32> | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#request-reply | |
struct StatusContent { | |
status: String, // "ok" | "abort" | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#streams-stdout-stderr-etc | |
struct StreamContent { | |
name: String, // "stdout" | "stderr" | |
text: String | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#display-data | |
struct DisplayDataContent { | |
data: Value, | |
metadata: Option<Value>, | |
transient: Option<Value> | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#update-display-data | |
// struct UpdateDisplayDataContent {} // same as DisplayDataContent | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-inputs | |
struct ExecuteInputContent { | |
code: String, | |
execution_count: u32 | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#id6 | |
struct ExecuteResultContent { | |
execution_count: u32, | |
data: Option<Value>, | |
metadata: Option<Value> | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#execution-errors | |
struct ErrorContent { | |
payload: Option<Vec<String>>, | |
user_expressions: Option<Value>, | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-status | |
struct KernelStatusContent { | |
execution_state: String, // "busy" | "idle" | "starting" | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#clear-output | |
struct ClearOutputContent { | |
wait: bool | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#debug-event | |
// struct DebugEventContent {} // see Event message from the Debug Adapter Protocol (DAP) | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#opening-a-comm | |
struct CommOpenMessage { | |
comm_id: uuid::Uuid, | |
target_name: String, | |
data: Option<Value>, | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-messages | |
struct CommMsgMessage { | |
comm_id: uuid::Uuid, | |
data: Option<Value>, | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#comm-messages | |
struct CommCloseMessage { | |
comm_id: uuid::Uuid, | |
data: Option<Value>, | |
} | |
/* ***************** | |
* STDIN MESSAGES | |
* *****************/ | |
// Stdin Request Message Types | |
// "input_request" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-channel | |
// Stdin Reply Message Types | |
// "input_reply" // https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-channel | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-channel | |
struct InputRequestContent { | |
prompt: String, | |
password: bool | |
} | |
// https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-channel | |
struct InputReplyContent { | |
value: String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment