From d8d4d66e2393a0879c85659bc4b5e8090d569455 Mon Sep 17 00:00:00 2001 From: Matt Kafonek Date: Mon, 25 Dec 2023 13:54:15 -0500 Subject: [PATCH] quality of life tweaks after trying to use kernel sidecar in a plugin --- src/nb_builder.rs | 4 ++++ src/notebook.rs | 4 ++++ 2 files changed, 8 insertions(+) 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)]