jupyter_protocol

Module messaging

Source
Expand description

Defines the core message types and structures for the Jupyter messaging protocol.

This module provides implementations for all message types specified in the Jupyter Client documentation, including execute requests/replies, completion, inspection, and more.

§Overview

The Jupyter messaging protocol is a set of JSON-based message types used to communicate between Jupyter clients and kernels. This module provides Rust types and utilities to work with these messages in a type-safe manner.

§Main Types

§Examples

§Creating an Execute Request

use jupyter_protocol::{ExecuteRequest, JupyterMessage};

// Create a new execute request with the code to be executed
let execute_request = ExecuteRequest::new("print('Hello, world!')".to_string());

// Convert the request into a JupyterMessage
let message: JupyterMessage = execute_request.into();

§Handling a Received Message

use jupyter_protocol::{JupyterMessage, JupyterMessageContent};

fn handle_message(msg: JupyterMessage) {
    match msg.content {
        JupyterMessageContent::ExecuteRequest(req) => {
            println!("Received execute request with code: {}", req.code);
        },
        JupyterMessageContent::KernelInfoRequest(_) => {
            println!("Received kernel info request");
        },
        _ => println!("Received other message type"),
    }
}

Re-exports§

Structs§

Enums§