Skip to main content

lensbench_engine/session/
proto.rs

1//! serve の method の名前・書式の版と、method ごとの鍵の取り方
2
3/// serve の method の名前(`describe` が返す。`handle` の match と試験で突き合わせる)
4pub const METHODS: &[&str] = &[
5    "ping",
6    "progress",
7    "cancel",
8    "stop",
9    "describe",
10    "shutdown",
11    "echo",
12    "load",
13    "reload",
14    "system",
15    "undo",
16    "redo",
17    "history",
18    "get",
19    "set",
20    "write",
21    "edit",
22    "surface",
23    "surface_data",
24    "system_data",
25    "config_table",
26    "config_diff",
27    "save",
28    "save_project",
29    "write_back",
30    "save_range",
31    "analyze",
32    "glasses",
33    "lenses",
34    "catalog_search",
35    "trace",
36    "plugins",
37    "catalog_add",
38    "catalog_items",
39    "catalog_edit",
40    "catalog_fill",
41    "cad_step",
42    "analysis_args",
43    "plugin",
44    "layout",
45    "layout_export",
46    "configs",
47    "optimize",
48    "swap",
49    "tolerance",
50    "zoom",
51];
52
53/// 書式の版(枠組み・method の約束を壊す変更で上げる)
54pub const PROTOCOL: u32 = 1;
55
56/// 要求の鍵の取り方
57#[derive(Clone, Copy, PartialEq, Debug)]
58pub enum Access {
59    /// 系を読むだけ(並行に回す)
60    Read,
61    /// 系や場の外のファイルを変える(1 つずつ)
62    Write,
63    /// 長い計算(始めたときの系で回し、他の要求を止めない。長い要求どうしは 1 つずつ)
64    Long,
65}
66
67impl Access {
68    /// method の鍵の取り方(知らない method は Write)
69    pub fn of(method: &str) -> Access {
70        match method {
71            "ping" | "describe" | "echo" | "system" | "history" | "get" | "surface"
72            | "surface_data" | "system_data" | "config_table" | "configs" | "analyze" | "trace"
73            | "plugin" | "plugins" | "analysis_args" | "layout" | "glasses" | "lenses"
74            | "catalog_search" | "preview" => Access::Read,
75            "optimize" | "tolerance" | "swap" | "zoom" => Access::Long,
76            _ => Access::Write,
77        }
78    }
79}