kernel_sidecar/jupyter/
request.rs1use crate::jupyter::message::Message;
10use crate::jupyter::shell_content::execute::ExecuteRequest;
11use crate::jupyter::shell_content::kernel_info::KernelInfoRequest;
12use crate::jupyter::wire_protocol::WireProtocol;
13
14#[derive(Debug)]
15pub enum Request {
16 KernelInfo(Message<KernelInfoRequest>),
17 Execute(Message<ExecuteRequest>),
18}
19
20impl Request {
21 pub fn msg_id(&self) -> String {
22 match self {
24 Request::KernelInfo(msg) => msg.header.msg_id.to_owned(),
25 Request::Execute(msg) => msg.header.msg_id.to_owned(),
26 }
27 }
28
29 pub fn into_wire_protocol(&self, hmac_signing_key: &str) -> WireProtocol {
30 match self {
31 Request::KernelInfo(msg) => WireProtocol::new(
32 msg.header.clone(),
33 Some(msg.content.clone()),
34 hmac_signing_key,
35 ),
36 Request::Execute(msg) => WireProtocol::new(
37 msg.header.clone(),
38 Some(msg.content.clone()),
39 hmac_signing_key,
40 ),
41 }
42 }
43}