-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlib.rs
More file actions
50 lines (42 loc) · 1.61 KB
/
lib.rs
File metadata and controls
50 lines (42 loc) · 1.61 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pub mod bindings;
pub mod conversion;
pub mod wrapper;
#[macro_export]
macro_rules! export {
{
root_fs_tar: $root_fs_tar:ident,
scalar_udfs: $scalar_udfs:ident,
} => {
#[derive(Debug)]
struct Implementation;
impl $crate::bindings::exports::datafusion_udf_wasm::udf::types::Guest for Implementation {
type ScalarUdf = $crate::wrapper::ScalarUdfWrapper;
fn root_fs_tar() -> Option<Vec<u8>> {
$root_fs_tar()
}
fn scalar_udfs(
source: String,
) -> Result<
Vec<$crate::bindings::exports::datafusion_udf_wasm::udf::types::ScalarUdf>,
$crate::bindings::exports::datafusion_udf_wasm::udf::types::DataFusionError,
> {
let udfs = $scalar_udfs(source)?;
Ok(
udfs.into_iter()
.map(|udf| $crate::bindings::exports::datafusion_udf_wasm::udf::types::ScalarUdf::new(
$crate::wrapper::ScalarUdfWrapper::new(udf)
))
.collect()
)
}
}
// only export on WASI, because otherwise the linker is going to be sad
#[cfg(target_os = "wasi")]
$crate::bindings::_export!(Implementation with_types_in $crate::bindings);
// create dummy function for other targets to suppress "unused" warnings
#[cfg(not(target_os = "wasi"))]
pub fn _export_stuff() -> impl $crate::bindings::exports::datafusion_udf_wasm::udf::types::Guest {
Implementation
}
};
}