#open-harmony #derive #macro #applications #binding #input-event #match

macro openharmony-ability-derive

Binding Rust application macro on Harmony with Ability

4 releases

new 0.1.0 Mar 21, 2025
0.0.3 Feb 20, 2025
0.0.2 Feb 12, 2025
0.0.1 Jan 24, 2025

#41 in #open-harmony

Download history 141/week @ 2025-01-22 3/week @ 2025-01-29 48/week @ 2025-02-05 150/week @ 2025-02-12 175/week @ 2025-02-19 17/week @ 2025-02-26 10/week @ 2025-03-12

208 downloads per month

MIT/Apache

5KB

openharmony-ability-derive

Introduce

openharmony-ability-derive is a macro crate for the openharmony-ability project. It provides a macro for generating code to accept the OpenHarmony/HarmonyNext ability's lifecycle callbacks.

Install

cargo add openharmony-ability-derive

Example

use openharmony_ability_derive::ability;

#[ability]
fn openharmony_app(app: OpenHarmonyApp) {
    app.run_loop(|types| match types {
        Event::Input(k) => match k {
            InputEvent::TextInputEvent(s) => {
                hilog_info!(format!("ohos-rs macro input_text: {:?}", s).as_str());
            }
            _ => {
                hilog_info!(format!("ohos-rs macro input:").as_str());
            }
        },
        Event::WindowRedraw(_) => {}
        _ => {
            hilog_info!(format!("ohos-rs macro: {:?}", types.as_str()).as_str());
        }
    });
}

Dependencies

~200–630KB
~15K SLoC