1use scripting::runtime::{alloc_pair_chain, alloc_string_ref};
13use wasmtime::{AnyRef, ArrayRef, Caller, Linker, Rooted, StructRef};
14
15use crate::session::SessionData;
16
17pub(crate) type StringArg = Option<Rooted<ArrayRef>>;
22pub(crate) type StringArgTriple = (StringArg, StringArg, StringArg);
25
26pub(crate) async fn alloc_string_pair_chain(
28 caller: &mut Caller<'_, SessionData>,
29 lines: Vec<String>,
30) -> wasmtime::Result<Option<Rooted<StructRef>>> {
31 let mut anyrefs: Vec<Option<Rooted<AnyRef>>> = Vec::with_capacity(lines.len());
32 for line in lines {
33 let s = alloc_string_ref(caller, line.as_bytes())?;
34 anyrefs.push(Some(s.to_anyref()));
35 }
36 alloc_pair_chain(caller, anyrefs).await
37}
38
39pub mod account;
40mod args;
41pub mod catch_each;
42pub mod chart;
43pub mod commodity;
44pub mod config;
45pub mod date;
46pub mod env_io;
47pub mod forms;
48mod generated_specs;
49pub mod meta;
50pub(crate) mod native;
51pub mod raise;
52mod render;
53pub mod report;
54pub mod script_store;
55pub mod split;
56pub mod ssh_key;
57pub mod tag;
58pub mod template;
59pub mod template_store;
60pub mod transaction;
61
62pub use generated_specs::all_compiler_specs;
63pub use render::{RENDER_NATIVE_ALLOWLIST, link_render, render_compiler_specs};
64
65pub fn link(linker: &mut Linker<SessionData>) -> wasmtime::Result<()> {
70 meta::register(linker)?;
71 env_io::register(linker)?;
72 raise::register(linker)?;
73 catch_each::register(linker)?;
74 chart::register(linker)?;
75 account::register(linker)?;
76 commodity::register(linker)?;
77 config::register(linker)?;
78 date::register(linker)?;
79 forms::register(linker)?;
80 report::register(linker)?;
81 split::register(linker)?;
82 ssh_key::register(linker)?;
83 tag::register(linker)?;
84 script_store::register(linker)?;
85 template_store::register(linker)?;
86 template::register(linker)?;
87 transaction::register(linker)?;
88 Ok(())
89}
90
91#[must_use]
97pub fn all_registered_commands() -> Vec<&'static str> {
98 [
99 account::REGISTERED_COMMANDS,
100 chart::REGISTERED_COMMANDS,
101 commodity::REGISTERED_COMMANDS,
102 config::REGISTERED_COMMANDS,
103 date::REGISTERED_COMMANDS,
104 forms::REGISTERED_COMMANDS,
105 report::REGISTERED_COMMANDS,
106 split::REGISTERED_COMMANDS,
107 script_store::REGISTERED_COMMANDS,
108 ssh_key::REGISTERED_COMMANDS,
109 tag::REGISTERED_COMMANDS,
110 template_store::REGISTERED_COMMANDS,
111 transaction::REGISTERED_COMMANDS,
112 ]
113 .iter()
114 .flat_map(|d| d.iter().copied())
115 .collect()
116}
117
118#[cfg(test)]
119#[path = "tests_registry.rs"]
120mod tests;