pub struct JupyterMessage {
pub zmq_identities: Vec<Bytes>,
pub header: Header,
pub parent_header: Option<Header>,
pub metadata: Value,
pub content: JupyterMessageContent,
pub buffers: Vec<Bytes>,
pub channel: Option<Channel>,
}
Expand description
A message in the Jupyter protocol format.
A Jupyter message consists of several parts:
zmq_identities
: ZeroMQ identities used for routing (not serialized)header
: Metadata about the messageparent_header
: Header from parent message, if this is a responsemetadata
: Additional metadata as JSONcontent
: The main message contentbuffers
: Binary buffers for messages that need them (not serialized)channel
: The communication channel this message belongs to
§Example
use jupyter_protocol::messaging::{JupyterMessage, JupyterMessageContent, ExecuteRequest};
// Create a new execute_request message
let msg = JupyterMessage::new(
ExecuteRequest {
code: "print('Hello')".to_string(),
silent: false,
store_history: true,
user_expressions: Default::default(),
allow_stdin: true,
stop_on_error: false,
},
None,
);
Messages can be created as responses to other messages by passing the parent:
let reply = JupyterMessage::new(
ExecuteReply {
status: ReplyStatus::Ok,
execution_count: jupyter_protocol::ExecutionCount::new(1),
..Default::default()
},
Some(&parent),
);
Fields§
§zmq_identities: Vec<Bytes>
§header: Header
§parent_header: Option<Header>
§metadata: Value
§content: JupyterMessageContent
§buffers: Vec<Bytes>
§channel: Option<Channel>
Implementations§
Source§impl JupyterMessage
impl JupyterMessage
pub fn new( content: impl Into<JupyterMessageContent>, parent: Option<&JupyterMessage>, ) -> JupyterMessage
pub fn with_metadata(self, metadata: Value) -> Self
pub fn with_buffers(self, buffers: Vec<Bytes>) -> Self
pub fn with_parent(self, parent: &JupyterMessage) -> Self
pub fn with_zmq_identities(self, zmq_identities: Vec<Bytes>) -> Self
pub fn with_session(self, session: &str) -> Self
pub fn message_type(&self) -> &str
pub fn from_value(message: Value) -> Result<JupyterMessage, Error>
Trait Implementations§
Source§impl Clone for JupyterMessage
impl Clone for JupyterMessage
Source§fn clone(&self) -> JupyterMessage
fn clone(&self) -> JupyterMessage
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 JupyterMessage
impl Debug for JupyterMessage
Source§impl<'de> Deserialize<'de> for JupyterMessage
impl<'de> Deserialize<'de> for JupyterMessage
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<ClearOutput> for JupyterMessage
impl From<ClearOutput> for JupyterMessage
Source§impl From<CommClose> for JupyterMessage
impl From<CommClose> for JupyterMessage
Source§impl From<CommInfoReply> for JupyterMessage
impl From<CommInfoReply> for JupyterMessage
Source§impl From<CommInfoRequest> for JupyterMessage
impl From<CommInfoRequest> for JupyterMessage
Source§impl From<CommMsg> for JupyterMessage
impl From<CommMsg> for JupyterMessage
Source§impl From<CommOpen> for JupyterMessage
impl From<CommOpen> for JupyterMessage
Source§impl From<CompleteReply> for JupyterMessage
impl From<CompleteReply> for JupyterMessage
Source§impl From<CompleteRequest> for JupyterMessage
impl From<CompleteRequest> for JupyterMessage
Source§impl From<DebugReply> for JupyterMessage
impl From<DebugReply> for JupyterMessage
Source§impl From<DebugRequest> for JupyterMessage
impl From<DebugRequest> for JupyterMessage
Source§impl From<DisplayData> for JupyterMessage
impl From<DisplayData> for JupyterMessage
Source§impl From<ErrorOutput> for JupyterMessage
impl From<ErrorOutput> for JupyterMessage
Source§impl From<ExecuteInput> for JupyterMessage
impl From<ExecuteInput> for JupyterMessage
Source§impl From<ExecuteReply> for JupyterMessage
impl From<ExecuteReply> for JupyterMessage
Source§impl From<ExecuteRequest> for JupyterMessage
impl From<ExecuteRequest> for JupyterMessage
Source§impl From<ExecuteResult> for JupyterMessage
impl From<ExecuteResult> for JupyterMessage
Source§impl From<HistoryReply> for JupyterMessage
impl From<HistoryReply> for JupyterMessage
Source§impl From<HistoryRequest> for JupyterMessage
impl From<HistoryRequest> for JupyterMessage
Source§impl From<InputReply> for JupyterMessage
impl From<InputReply> for JupyterMessage
Source§impl From<InputRequest> for JupyterMessage
impl From<InputRequest> for JupyterMessage
Source§impl From<InspectReply> for JupyterMessage
impl From<InspectReply> for JupyterMessage
Source§impl From<InspectRequest> for JupyterMessage
impl From<InspectRequest> for JupyterMessage
Source§impl From<InterruptReply> for JupyterMessage
impl From<InterruptReply> for JupyterMessage
Source§impl From<InterruptRequest> for JupyterMessage
impl From<InterruptRequest> for JupyterMessage
Source§impl From<IsCompleteReply> for JupyterMessage
impl From<IsCompleteReply> for JupyterMessage
Source§impl From<IsCompleteRequest> for JupyterMessage
impl From<IsCompleteRequest> for JupyterMessage
Source§impl From<JupyterMessageContent> for JupyterMessage
impl From<JupyterMessageContent> for JupyterMessage
Source§fn from(content: JupyterMessageContent) -> Self
fn from(content: JupyterMessageContent) -> Self
Converts to this type from the input type.
Source§impl From<KernelInfoReply> for JupyterMessage
impl From<KernelInfoReply> for JupyterMessage
Source§fn from(content: KernelInfoReply) -> Self
fn from(content: KernelInfoReply) -> Self
Converts to this type from the input type.
Source§impl From<KernelInfoRequest> for JupyterMessage
impl From<KernelInfoRequest> for JupyterMessage
Source§impl From<ShutdownReply> for JupyterMessage
impl From<ShutdownReply> for JupyterMessage
Source§impl From<ShutdownRequest> for JupyterMessage
impl From<ShutdownRequest> for JupyterMessage
Source§impl From<Status> for JupyterMessage
impl From<Status> for JupyterMessage
Source§impl From<StreamContent> for JupyterMessage
impl From<StreamContent> for JupyterMessage
Source§impl From<UnknownMessage> for JupyterMessage
impl From<UnknownMessage> for JupyterMessage
Source§impl From<UpdateDisplayData> for JupyterMessage
impl From<UpdateDisplayData> for JupyterMessage
Auto Trait Implementations§
impl Freeze for JupyterMessage
impl RefUnwindSafe for JupyterMessage
impl Send for JupyterMessage
impl Sync for JupyterMessage
impl Unpin for JupyterMessage
impl UnwindSafe for JupyterMessage
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