kataglyphis_rustprojecttemplate/api/
simple.rs

1#[flutter_rust_bridge::frb(sync)]
2pub fn greet(name: String) -> String {
3    format!("Hello, you {name}!")
4}
5
6// `init_app` is platform-specific and provided from `crate::platform`.
7// Keep `greet`, `heavy_computation`, and async helpers here.
8
9/// Forwarding shim for platform-specific initialization.
10/// The real implementation lives in `crate::platform` (wasm/native).
11pub fn init_app() {
12    crate::platform::init_app();
13}
14
15/// Synchronous heavy computation demo (template stub).
16#[flutter_rust_bridge::frb(sync)]
17pub fn heavy_computation(input: i32) -> i32 {
18    let mut result = input;
19    for _ in 0..1000 {
20        result = (result * 2) % 1000000;
21    }
22    result
23}
24
25/// Asynchronous work demo (template stub).
26#[flutter_rust_bridge::frb()]
27pub async fn async_heavy_work(input: i32) -> i32 {
28    tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
29    input * 2
30}