diff --git a/src/nb_builder.rs b/src/nb_builder.rs index 17c85d6..e0e1347 100644 --- a/src/nb_builder.rs +++ b/src/nb_builder.rs @@ -38,6 +38,10 @@ impl NotebookBuilder { self.nb.read().await.save(filename); } + pub async fn dumps(&self) -> String { + self.nb.read().await.dumps() + } + pub async fn get_cell(&self, id: &str) -> Option { let nb = self.nb.read().await; for cell in nb.cells.iter() { diff --git a/src/notebook.rs b/src/notebook.rs index 64b55ca..47b81c0 100644 --- a/src/notebook.rs +++ b/src/notebook.rs @@ -50,6 +50,10 @@ impl Notebook { let js = serde_json::to_string_pretty(&self).expect("Failed to serialize notebook on save"); std::fs::write(filename, js).unwrap(); } + + pub fn dumps(&self) -> String { + serde_json::to_string_pretty(&self).expect("Failed to serialize notebook on save") + } } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, EnumAsInner)]