{"id":43426195,"url":"https://github.com/harmony-contrib/openharmony-ability","last_synced_at":"2026-02-02T19:03:01.849Z","repository":{"id":273984974,"uuid":"881812719","full_name":"harmony-contrib/openharmony-ability","owner":"harmony-contrib","description":"Building application for OpenHarmony with Rust","archived":false,"fork":false,"pushed_at":"2025-12-31T07:38:42.000Z","size":794,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-04T10:49:52.903Z","etag":null,"topics":["harmonyos-next","openharmony","winit"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harmony-contrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-01T09:37:17.000Z","updated_at":"2025-12-31T07:38:42.000Z","dependencies_parsed_at":"2025-12-31T18:05:50.708Z","dependency_job_id":null,"html_url":"https://github.com/harmony-contrib/openharmony-ability","commit_stats":null,"previous_names":["harmony-contrib/openharmony-ability"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/harmony-contrib/openharmony-ability","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmony-contrib%2Fopenharmony-ability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmony-contrib%2Fopenharmony-ability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmony-contrib%2Fopenharmony-ability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmony-contrib%2Fopenharmony-ability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harmony-contrib","download_url":"https://codeload.github.com/harmony-contrib/openharmony-ability/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmony-contrib%2Fopenharmony-ability/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29017939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T18:51:31.335Z","status":"ssl_error","status_checked_at":"2026-02-02T18:49:20.777Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["harmonyos-next","openharmony","winit"],"created_at":"2026-02-02T19:03:01.758Z","updated_at":"2026-02-02T19:03:01.844Z","avatar_url":"https://github.com/harmony-contrib.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenHarmony Ability\n\n\u003e This project is in progress, and the API is not stable.\n\n`openharmony-ability` is a crate to manage OpenHarmony application's activity with rust, be similar to [android-activity](https://github.com/rust-mobile/android-activity).\n\n## Architecture\n\nThe architecture of OpenHarmony is similar to Node.js, where we need to manage the application's lifecycle via callbacks. Hence, there are a few key points to keep in mind.\n\n1. Don't block the main thread as it can lead to application freezing and crashing.\n2. openharmony-ability's run_loop doesn't retain the resource and ownership, so if you create a new resource, you should leak it to prevent NULL pointer.\n\n![Architecture](/fixtures/openharmony-ability.png)\n\nWe provide some packages or crates to help you develop OpenHarmony application with Rust.\n\n### ArkTS\n\nWe need a entry-point to start the application, and we use ArkTS to manage the application's lifecycle.\n\n- [@ohos-rs/ability](./package/README.md)  \n  All of ability need to extend `RustAbility` and all lifecycle need to call `super.xx` to make sure the ability can work normally.\n\n### Rust\n\n- [openharmony-ability](./crates/ability/README.md)  \n  Basic crate to manage the application's lifecycle.\n\n- [openharmony-ability-derive](./crates/derive/README.md)  \n  Macro to generate the ability's implementation.\n\n## Usage\n\n1. use `ohrs` to init project and add `openharmony-ability` dependencies.\n\n   ```bash\n   ohrs init hello\n\n   cargo add openharmony-ability\n   cargo add openharmony-ability-derive\n   ```\n\n   If you already have a rust project, you can add the dependencies into your project. And you need to add the following dependencies into your project which is used to generate some codes to bridge ArkTS.\n\n   ```bash\n   cargo add napi-ohos\n   cargo add napi-derive-ohos\n   cargo add napi-build-ohos\n   ```\n\n2. Add the follow code to `lib.rs`.\n\n   ```rust\n   use ohos_hilog_binding::hilog_info;\n   use openharmony_ability::App;\n   use openharmony_ability_derive::ability;\n\n   #[ability]\n   fn openharmony_app(app: App) {\n       app.run_loop(|types| {\n           hilog_info!(format!(\"ohos-rs macro: {:?}\", types.as_str()).as_str());\n       });\n   }\n   ```\n\n   \u003e Note: `ohos_hilog_binding` is a optional dependency and you can add or remove it.\n\n3. Add `@ohos-rs/ability` to your `OpenHarmony/HarmonyNext` project.\n\n   ```bash\n   ohpm install @ohos-rs/ability\n   ```\n\n4. change the `EntryAbility.ets` file to the follow code:\n\n   ```ts\n   import { RustAbility } from \"@ohos-rs/ability\";\n   import Want from \"@ohos.app.ability.Want\";\n   import { AbilityConstant } from \"@kit.AbilityKit\";\n\n   export default class EntryAbility extends RustAbility {\n     public moduleName: string = \"example\";\n\n     async onCreate(\n       want: Want,\n       launchParam: AbilityConstant.LaunchParam\n     ): Promise\u003cvoid\u003e {\n       // Note: you should call super.onCreate to make sure the ability can work normally.\n       super.onCreate(want, launchParam);\n     }\n   }\n   ```\n\n5. Change the `moduleName` to your rust project name. For example, we need to change it with `hello` in this project.\n\n6. Build your rust project and copy the dynamic library to (Open-)Harmony(Next) project.\n\n7. Now, you can enjoy it.\n\n## Example\n\nSee example with [example](./example/src/lib.rs)\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmony-contrib%2Fopenharmony-ability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharmony-contrib%2Fopenharmony-ability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmony-contrib%2Fopenharmony-ability/lists"}