spreadsheet_kit/
session.rs1use crate::types::CellEdit;
2use anyhow::{Result, bail};
3use std::path::{Path, PathBuf};
4
5pub trait SessionRuntime {
6 type Handle;
7
8 fn open(&self, workbook_path: &Path) -> Result<Self::Handle>;
9 fn apply_edits(
10 &self,
11 handle: &Self::Handle,
12 sheet_name: &str,
13 edits: &[CellEdit],
14 ) -> Result<()>;
15 fn recalculate(&self, handle: &Self::Handle, timeout_ms: Option<u64>) -> Result<()>;
16 fn save_as(&self, handle: &Self::Handle, output_path: &Path) -> Result<PathBuf>;
17}
18
19#[derive(Debug, Default, Clone)]
20pub struct SessionRuntimeScaffold;
21
22impl SessionRuntime for SessionRuntimeScaffold {
23 type Handle = String;
24
25 fn open(&self, _workbook_path: &Path) -> Result<Self::Handle> {
26 bail!("session runtime is scaffold-only in this ticket")
27 }
28
29 fn apply_edits(
30 &self,
31 _handle: &Self::Handle,
32 _sheet_name: &str,
33 _edits: &[CellEdit],
34 ) -> Result<()> {
35 bail!("session runtime is scaffold-only in this ticket")
36 }
37
38 fn recalculate(&self, _handle: &Self::Handle, _timeout_ms: Option<u64>) -> Result<()> {
39 bail!("session runtime is scaffold-only in this ticket")
40 }
41
42 fn save_as(&self, _handle: &Self::Handle, _output_path: &Path) -> Result<PathBuf> {
43 bail!("session runtime is scaffold-only in this ticket")
44 }
45}