Expand description
Provides types and utilities for working with rich media content in Jupyter messages.
This module defines the Media and MediaType structures, which represent
MIME bundles in Jupyter messages. These are used for rich content display
in notebooks and other Jupyter frontends.
The main types in this module are:
§Examples
Creating a media bundle with multiple types:
use jupyter_protocol::media::{Media, MediaType};
let media = Media::new(vec![
MediaType::Plain("Hello, world!".to_string()),
MediaType::Html("<h1>Hello, world!</h1>".to_string()),
]);Finding the richest media type:
use jupyter_protocol::media::{Media, MediaType};
let media = Media::new(vec![
MediaType::Plain("Hello, world!".to_string()),
MediaType::Html("<h1>Hello, world!</h1>".to_string()),
MediaType::Markdown("**Hello, world!**".to_string()),
]);
let richest = media.richest(|media_type| match media_type {
MediaType::Html(_) => 3,
MediaType::Markdown(_) => 2,
MediaType::Plain(_) => 1,
_ => 0,
});
assert!(matches!(richest, Some(MediaType::Html(_))));Re-exports§
pub use datatable::TabularDataResource;
Modules§
Structs§
- Media
- A
Mediais a collection of data associated with different Media types. It allows for the representation of rich content that can be displayed in multiple formats. These are found in thedatafield of aDisplayDataandExecuteResultmessages/output types.
Enums§
- Media
Type - An enumeration representing various Media types, otherwise known as MIME (Multipurpose Internet Mail Extensions) types.
These types are used to indicate the nature of the data in a rich content message such as
DisplayData,UpdateDisplayData, andExecuteResult.