pub struct UnknownMessage {
pub msg_type: String,
pub content: Value,
}
Expand description
Unknown message types are a workaround for generically unknown messages.
use jupyter_protocol::messaging::{JupyterMessage, JupyterMessageContent, UnknownMessage};
use serde_json::json;
let msg = UnknownMessage {
msg_type: "example_request".to_string(),
content: json!({ "key": "value" }),
};
let reply_msg = msg.reply(json!({ "status": "ok" }));
Fields§
§msg_type: String
§content: Value
Implementations§
Source§impl UnknownMessage
impl UnknownMessage
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 UnknownMessage
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::UnknownMessage;
let parent_message = JupyterMessage::new(jupyter_protocol::UnknownMessage {
msg_type: "example".to_string(),
content: serde_json::json!({ "key": "value" }),
}, None);
let child_message = UnknownMessage{
..Default::default()
}.as_child_of(&parent_message);
// Next you would send the `child_message` over the connection
Source§impl UnknownMessage
impl UnknownMessage
pub fn reply(&self, content: Value) -> JupyterMessageContent
Trait Implementations§
Source§impl Clone for UnknownMessage
impl Clone for UnknownMessage
Source§fn clone(&self) -> UnknownMessage
fn clone(&self) -> UnknownMessage
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for UnknownMessage
impl Debug for UnknownMessage
Source§impl Default for UnknownMessage
impl Default for UnknownMessage
Source§impl<'de> Deserialize<'de> for UnknownMessage
impl<'de> Deserialize<'de> for UnknownMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<UnknownMessage> for JupyterMessage
impl From<UnknownMessage> for JupyterMessage
Source§impl From<UnknownMessage> for JupyterMessageContent
impl From<UnknownMessage> for JupyterMessageContent
Source§fn from(content: UnknownMessage) -> Self
fn from(content: UnknownMessage) -> Self
Create a new JupyterMessageContent
for a UnknownMessage
.
Auto Trait Implementations§
impl Freeze for UnknownMessage
impl RefUnwindSafe for UnknownMessage
impl Send for UnknownMessage
impl Sync for UnknownMessage
impl Unpin for UnknownMessage
impl UnwindSafe for UnknownMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more