new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Tauri · Plugins and security · all subjects

advanced plugin configuration

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Calling Rust from Android plugins using JNI

To call Rust from Android plugin code, use JNI (Java Native Interface). Add the jni crate as a dependency with `[target.'cfg(target_os = "android")'.dependencies] jni = "0.21"`. Load the application library statically with `System.loadLibrary("app_lib")` and define native functions in Kotlin. In Rust code, define the function with format `Java_package_class_method`, for example `Java_com_example_HelloWorld_helloWorld`.

Calling Rust from iOS plugins using FFI

iOS uses standard C FFI and does not need any new dependencies. Add the hook in Swift code with `@_silgen_name("function_name")` annotation. Define the corresponding `extern "C"` Rust function with matching signature. Use `@no_mangle` and `extern "C"` attributes on the Rust side.

Plugin configuration access on mobile

The plugin instance on mobile has a getter for the plugin configuration. On Android, use `getConfig(ConfigClass::class.java)` to retrieve the configuration in the `load` lifecycle event. On iOS, use `try parseConfig(Config.self)` to retrieve the configuration.

Android plugin configuration class with @InvokeArg

Android plugin configuration is defined as a class annotated with `@app.tauri.annotation.InvokeArg`. Fields can have default values. Access the configuration in the plugin's `load(webView: WebView)` override method using `getConfig(Config::class.java)`.

iOS plugin configuration with Decodable

iOS plugin configuration is defined as a struct inheriting `Decodable`. Access the configuration in the plugin's `load(webview: WKWebView)` override method using `try parseConfig(Config.self)` inside a do-catch block.

Android plugin configuration with getter command

Mobile plugin instances have getter commands for plugin configuration. In Android, use getConfig(Config::class.java) in the load() function to retrieve plugin configuration as defined by an @InvokeArg annotated class.

iOS plugin configuration retrieval

In iOS, use parseConfig(Config.self) in the load() override function to retrieve plugin configuration from a Decodable struct.

Give your agent this brain