1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use serde::{Deserialize, Serialize};

use crate::{CellId, SheetId};

#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "gents", derive(gents_derives::TS))]
#[cfg_attr(feature = "gents", ts(file_name = "task.ts"))]
pub struct Task {
    pub async_func: String,
    pub args: Vec<String>,
}

pub type AsyncCalcResult = Result<String, AsyncErr>;

#[derive(Debug, Clone)]
pub enum AsyncErr {
    ArgErr,
    TimeOut,
}

pub trait AsyncFuncCommitTrait {
    fn query_or_commit_task(
        &mut self,
        sheet_id: SheetId,
        cell_id: CellId,
        task: Task,
    ) -> Option<AsyncCalcResult>;
}