Skip to main content

oxidant/api/
simple.rs

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