pub struct StreamContent {
pub name: Stdio,
pub text: String,
}Expand description
A 'stream' message on the 'iopub' channel.
See Streams.
§Example
The UI/client sends an 'execute_request' message to the kernel.
use jupyter_protocol::messaging::{ExecuteRequest};
// From the UI
let execute_request = ExecuteRequest {
code: "print('Hello, World!')".to_string(),
silent: false,
store_history: true,
user_expressions: None,
allow_stdin: false,
stop_on_error: true,
};
connection.send(execute_request).await?;As a side effect of execution, the kernel can send 'stream' messages to the UI/client.
These are from using print(), console.log(), or similar. Anything on STDOUT or STDERR.
use jupyter_protocol::messaging::{StreamContent, Stdio};
let execute_request = shell.read().await?;
let message = StreamContent {
name: Stdio::Stdout,
text: "Hello, World".to_string()
}.as_child_of(execute_request);
iopub.send(message).await?;
Fields§
§name: Stdio§text: StringImplementations§
Source§impl StreamContent
impl StreamContent
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 StreamContent 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};
let message = connection.recv().await?;
let child_message = StreamContent{
// ...
}.as_child_of(&message);
connection.send(child_message).await?;Trait Implementations§
Source§impl Clone for StreamContent
impl Clone for StreamContent
Source§fn clone(&self) -> StreamContent
fn clone(&self) -> StreamContent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StreamContent
impl Debug for StreamContent
Source§impl<'de> Deserialize<'de> for StreamContent
impl<'de> Deserialize<'de> for StreamContent
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>,
Source§impl From<StreamContent> for JupyterMessage
impl From<StreamContent> for JupyterMessage
Source§fn from(content: StreamContent) -> Self
fn from(content: StreamContent) -> Self
Create a new JupyterMessage for a StreamContent.
⚠️ If you use this method, you must set the zmq identities yourself. If you have a message that
“caused” your message to be sent, use that message with as_child_of instead.
Source§impl From<StreamContent> for JupyterMessageContent
impl From<StreamContent> for JupyterMessageContent
Source§fn from(content: StreamContent) -> Self
fn from(content: StreamContent) -> Self
Create a new JupyterMessageContent for a StreamContent.