use std::collections::HashMap;
pub type NotebookCellType = String;
#[derive(Debug, Clone)]
pub struct NotebookCell {
pub cell_type: NotebookCellType,
pub source: Vec<String>,
pub metadata: HashMap<String, String>,
pub outputs: Vec<CellOutput>,
}
impl NotebookCell {
pub fn code(source: Vec<String>) -> Self {
Self {
cell_type: "code".to_string(),
source,
metadata: HashMap::new(),
outputs: Vec::new(),
}
}
pub fn markdown(source: Vec<String>) -> Self {
Self {
cell_type: "markdown".to_string(),
source,
metadata: HashMap::new(),
outputs: Vec::new(),
}
}
}
#[derive(Debug, Clone)]
pub enum CellOutput {
Text(String),
Error(String),
Image { mime_type: String, data: Vec<u8> },
}
pub struct Notebook {
pub cells: Vec<NotebookCell>,
pub metadata: HashMap<String, String>,
}
impl Notebook {
pub fn new() -> Self {
Self {
cells: Vec::new(),
metadata: HashMap::new(),
}
}
pub fn add_cell(&mut self, cell: NotebookCell) {
self.cells.push(cell);
}
}
impl Default for Notebook {
fn default() -> Self {
Self::new()
}
}