Macro tao_macros::generate_package_name

source ·
generate_package_name!() { /* proc-macro */ }
Expand description

Generate the package name used for invoking Java/Kotlin methods at compile-time

This macro expects 2 parameters:

  1. snake_case representation of the reversed domain of the app.
  2. snake_case representation of the package name.

Note that _ is the separator for the domain parts. For instance the com.tauri.app identifier should be represented as generate_package_name!(com_tauri, app). To escape the _ character you can use _1 which aligns with the default NDK implementation.

§Example


const PACKAGE_NAME: &str = generate_package_name!(com_example, tao_app);

which can be used later on with JNI:


const PACKAGE_NAME: &str = generate_package_name!(com_example, tao_app); // constructs `com/example/tao_app`
let ipc_class = find_my_class(env, activity, format!("{}/Ipc", PACKAGE_NAME)).unwrap();