pub struct CommOpen {
pub comm_id: CommId,
pub target_name: String,
pub data: Map<String, Value>,
}
Expand description
A comm_open
message on the iopub
channel.
See Comm Open.
Comm messages are one-way communications to update comm state, used for synchronizing widget state, or simply requesting actions of a comm’s counterpart.
Opening a Comm produces a comm_open
message, to be sent to the other side:
{
"comm_id": "u-u-i-d",
"target_name": "my_comm",
"data": {}
}
Every Comm has an ID and a target name. The code handling the message on
the receiving side is responsible for maintaining a mapping of target_name
keys to constructors. After a comm_open
message has been sent, there
should be a corresponding Comm instance on both sides. The data key is
always a object with any extra JSON information used in initialization of
the comm.
If the target_name
key is not found on the receiving side, then it should
immediately reply with a comm_close
message to avoid an inconsistent state.
Fields§
§comm_id: CommId
§target_name: String
§data: Map<String, Value>
Implementations§
Source§impl CommOpen
impl CommOpen
Sourcepub fn as_child_of(&self, parent: &JupyterMessage) -> JupyterMessage
pub fn as_child_of(&self, parent: &JupyterMessage) -> JupyterMessage
Create a new JupyterMessage
, assigning the parent for a CommOpen
message.
This method creates a new JupyterMessage
with the right content, parent header, and zmq identities, making
it suitable for sending over ZeroMQ.
§Example
use jupyter_protocol::messaging::{JupyterMessage, JupyterMessageContent};
use jupyter_protocol::CommOpen;
let parent_message = JupyterMessage::new(jupyter_protocol::UnknownMessage {
msg_type: "example".to_string(),
content: serde_json::json!({ "key": "value" }),
}, None);
let child_message = CommOpen{
..Default::default()
}.as_child_of(&parent_message);
// Next you would send the `child_message` over the connection