|
1 | 1 | /* SPDX-License-Identifier: GPL-3.0-or-later */ |
2 | 2 | /* Copyright © 2026 Eduard Smet */ |
3 | 3 |
|
4 | | -interface core-types { |
5 | | - type json = string; |
6 | | - |
7 | | - type host-error = string; |
| 4 | +use wpbs:shared/shared-types@0.1.0-rc.1; |
8 | 5 |
|
9 | | - type plugin-error = string; |
| 6 | +world core { |
| 7 | + import core-import-functions; |
| 8 | + export core-export-functions; |
10 | 9 | } |
11 | 10 |
|
12 | | -interface core-import-types { |
13 | | - use core-types.{host-error}; |
14 | | - |
15 | | - // Services |
16 | | - use job-scheduler-import-types.{job-scheduler-registrations, job-scheduler-registrations-result, job-scheduler-deregistrations, job-scheduler-deregistrations-result}; |
17 | | - use discord-import-types.{discord-registrations, discord-registrations-result, discord-deregistrations, discord-deregistrations-result}; |
18 | | - |
| 11 | +interface core-types { |
19 | 12 | enum log-levels { |
20 | 13 | trace, |
21 | 14 | debug, |
22 | 15 | info, |
23 | 16 | warn, |
24 | 17 | error, |
25 | 18 | } |
26 | | - |
27 | | - record registrations { |
28 | | - core: option<core-registrations>, |
29 | | - services: option<services-registrations>, |
30 | | - } |
31 | | - |
32 | | - record core-registrations { |
33 | | - dependency-functions: option<list<string>>, |
34 | | - } |
35 | | - |
36 | | - record services-registrations { |
37 | | - job-scheduler: option<job-scheduler-registrations>, |
38 | | - discord: option<discord-registrations>, |
39 | | - } |
40 | | - |
41 | | - record registrations-result { |
42 | | - core: option<core-registrations-result>, |
43 | | - services: option<services-registrations-result>, |
44 | | - } |
45 | | - |
46 | | - record core-registrations-result { |
47 | | - dependency-functions: option<result<map<string, string>, host-error>>, |
48 | | - } |
49 | | - |
50 | | - record services-registrations-result { |
51 | | - job-scheduler: option<result<job-scheduler-registrations-result, host-error>>, |
52 | | - discord: option<result<discord-registrations-result, host-error>> |
53 | | - } |
54 | | - |
55 | | - record deregistrations { |
56 | | - core: option<core-deregistrations>, |
57 | | - services: option<services-deregistrations>, |
58 | | - } |
59 | | - |
60 | | - record core-deregistrations { |
61 | | - dependency-functions: option<list<string>> |
62 | | - } |
63 | | - |
64 | | - record services-deregistrations { |
65 | | - job-scheduler: option<job-scheduler-deregistrations>, |
66 | | - discord: option<discord-deregistrations>, |
67 | | - } |
68 | | - |
69 | | - record deregistrations-result { |
70 | | - core: option<core-deregistrations-result>, |
71 | | - services: option<services-deregistrations-result>, |
72 | | - } |
73 | | - |
74 | | - record core-deregistrations-result { |
75 | | - dependency-functions: option<list<string>> |
76 | | - } |
77 | | - |
78 | | - record services-deregistrations-result { |
79 | | - job-scheduler: option<result<job-scheduler-deregistrations-result, host-error>>, |
80 | | - discord: option<result<discord-deregistrations-result, host-error>>, |
81 | | - } |
82 | 19 | } |
83 | 20 |
|
84 | 21 | interface core-import-functions { |
85 | | - use core-types.{host-error}; |
86 | | - use core-import-types.{deregistrations, deregistrations-result, log-levels, registrations, registrations-result}; |
87 | | - |
88 | | - |
89 | | - register: func(registrations: registrations) -> registrations-result; |
90 | | - deregister: func(deregistrations: deregistrations) -> deregistrations-result; |
| 22 | + use core-types.{log-levels}; |
| 23 | + use shared-types.{host-error}; |
91 | 24 |
|
92 | 25 | log: func(level: log-levels, message: string); |
93 | 26 |
|
94 | | - get-state: func(key: string) -> result<option<list<u8>>, host-error>; |
95 | | - set-state: func(key: string, value: list<u8>) -> result<_, host-error>; |
96 | | - clear-state: func() -> result<_, host-error>; |
| 27 | + get-value: func(key: string) -> result<option<list<u8>>, host-error>; |
| 28 | + set-value: func(key: string, value: list<u8>) -> result<_, host-error>; |
| 29 | + remove-value: func(key: string) -> result<option<list<u8>>, host-error>; |
97 | 30 |
|
98 | | - dependency-function: func(registry-id: string, plugin-id: string, function-id: string, plugin-version: option<string>, params: list<u8>) -> result<list<u8>, host-error>; |
| 31 | + get-all-entries: func() -> result<list<tuple<string, list<u8>>>, host-error>; |
| 32 | + clear-all-entries: func() -> result<_, host-error>; |
99 | 33 |
|
100 | | - remove: func(reason: string); |
101 | 34 | shutdown: func(restart: bool) -> result<_, host-error>; |
102 | 35 | } |
103 | 36 |
|
104 | 37 | interface core-export-functions { |
105 | | - use core-types.{json, plugin-error}; |
| 38 | + use shared-types.{json, plugin-error}; |
106 | 39 |
|
107 | 40 | initialization: func(settings: json) -> result<_, plugin-error>; |
108 | 41 |
|
109 | | - dependency-function: func(function-id: string, params: list<u8>) -> result<list<u8>, plugin-error>; |
110 | | - |
111 | 42 | shutdown: func() -> result<_, plugin-error>; |
112 | 43 | } |
113 | 44 |
|
0 commit comments