Crate jupyter_protocol

Source
Expand description

§Jupyter Protocol

This crate provides a complete implementation of the Jupyter messaging protocol, as specified in the Jupyter Client documentation.

It includes types and structures for all Jupyter message types, as well as utilities for working with Jupyter kernels and clients.

§Main Components

  • JupyterMessage: The main message type, encompassing all Jupyter protocol messages.
  • JupyterMessageContent: An enum representing the various content types for Jupyter messages.
  • Media: Represents rich media content (MIME bundles) in Jupyter messages.
  • ConnectionInfo: Contains information needed to connect to a Jupyter kernel.

§Usage

Here’s a basic example of creating and working with Jupyter messages:

use jupyter_protocol::{JupyterMessage, ExecuteRequest, JupyterMessageContent};

// Create an execute request
let execute_request = ExecuteRequest::new("print('Hello, world!')".to_string());

// Convert it to a JupyterMessage
let message: JupyterMessage = execute_request.into();

// You can then send this message using your preferred transport layer

// When receiving messages, you can match on the content type:
match message.content {
    JupyterMessageContent::ExecuteRequest(req) => {
        println!("Received execute request with code: {}", req.code);
    },
    _ => println!("Received other message type"),
}

For more detailed examples and usage information, see the documentation for individual modules and types.

Re-exports§

Modules§

  • Defines structures and functions for Jupyter kernel connection information.
  • Provides types and utilities for working with rich media content in Jupyter messages.
  • Defines the core message types and structures for the Jupyter messaging protocol.

Structs§

  • Represents a monotonically increasing counter for tracking the number of code executions in a Jupyter session. This count is maintained across all executions, including those in notebook cells and via terminal execute_requests.
  • Represents the contents of a Jupyter JSON kernelspec file.

Traits§