macro_rules! js_reexport {
(
// # Args
// [ header section
// $module: optional js module name (defaults to "env")
// ]
// $fn_attrs: optional attributes and doc comments
// $vis: visibility of the extern function (defaults to private)
// safe|unsafe optional safety specifier (defaults to unsafe)
// $js_fn: optional link_name (different javascript function name)
// $fn: imported rust function name (default same js name)
[
$(module: $module:literal)? $(,)?
]
$(
$(#[$fn_attrs:meta])*
$vis:vis $(safe$($_s:block)?)? $(unsafe$($_u:block)?)?
fn
$($js_fn:literal)?
$fn:ident
($($param:ident: $param_ty:ty),* $(,)?) $(-> $fn_return:ty)?;
)*
) => { ... };
}
Available on crate features
js
and unsafe_ffi
only.Expand description
Helps re-exporting javascript functions.
§Example
js_reexport! {
[ module: "env" ]
pub safe fn same_fn_name(x: f64, y: f64, w: f64, h: f64);
pub(crate) safe fn "js_fn_name" rust_fn_name(x: f64, y: f64, w: f64, h: f64);
unsafe fn "js_fn" rs_fn(ptr: *const u8, len: usize, x: f64, y: f64);
}