{"id":15008605,"url":"https://github.com/dart-sys/dart-sys","last_synced_at":"2025-04-07T17:11:49.647Z","repository":{"id":57616154,"uuid":"211717150","full_name":"dart-sys/dart-sys","owner":"dart-sys","description":"Rust bindings to the dart native extensions api","archived":false,"fork":false,"pushed_at":"2024-03-09T02:37:52.000Z","size":32329,"stargazers_count":43,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T14:14:46.440Z","etag":null,"topics":["dart","dart-ffi","dart-lang","dart-rust","ffi","flutter","flutter-dart","flutter-rust","flutter-rust-bridge","rust","rust-dart","rust-lang"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/dart-sys","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dart-sys.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE-2.0.md","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2019-09-29T19:45:56.000Z","updated_at":"2025-02-01T20:40:17.000Z","dependencies_parsed_at":"2024-03-08T04:22:04.948Z","dependency_job_id":"011bcad7-ec5c-4bd9-a18c-cac3a81bc5a0","html_url":"https://github.com/dart-sys/dart-sys","commit_stats":{"total_commits":170,"total_committers":3,"mean_commits":"56.666666666666664","dds":0.1588235294117647,"last_synced_commit":"b6ac7e5df032faa0df1ba9392bac203943e81c33"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dart-sys%2Fdart-sys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dart-sys%2Fdart-sys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dart-sys%2Fdart-sys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dart-sys%2Fdart-sys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dart-sys","download_url":"https://codeload.github.com/dart-sys/dart-sys/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694877,"owners_count":20980733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["dart","dart-ffi","dart-lang","dart-rust","ffi","flutter","flutter-dart","flutter-rust","flutter-rust-bridge","rust","rust-dart","rust-lang"],"created_at":"2024-09-24T19:19:41.119Z","updated_at":"2025-04-07T17:11:49.615Z","avatar_url":"https://github.com/dart-sys.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dart-Sys\n\n\u003cp align=\"center\"\u003e\n  \u003cimg\n    src=\"https://raw.githubusercontent.com/dart-sys/dart-sys-branding-assets/main/dart-sys%20header.png\"\n    alt=\"Dart-sys brand header\"\n  \u003e\n  \u003cbr/\u003e\n  \u003cbr/\u003e\n\u003c/p\u003e\n\n# Dart-sys\n\n[![Stars](https://img.shields.io/github/stars/dart-sys/dart-sys)](https://github.com/dart-sys/dart-sys/stargazers)\n[![Forks](https://img.shields.io/github/forks/dart-sys/dart-sys)](https://github.com/dart-sys/dart-sys/network/members)\n[![Crates.io](https://img.shields.io/crates/v/dart-sys.svg)](https://crates.io/crates/dart-sys)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Docs.rs](https://docs.rs/dart-sys/badge.svg)](https://docs.rs/dart-sys)\n[![CI](https://github.com/dart-sys/dart-sys/actions/workflows/ci.yml/badge.svg)](https://github.com/dart-sys/dart-sys/actions/workflows/ci.yml)\n\n\u003e _Rust bindings to the [Dart ffi api](https://dart.dev/guides/libraries/c-interop)_\n\n## Prerequisites 🔧\n\nYou will need the following tools available on your system:\n\n- [Dart](https://dart.dev/get-dart) version 2.12 or higher\n- [Rust](https://www.rust-lang.org/tools/install) version 1.51 or higher\n- [Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html)\n- [Git](https://git-scm.com/downloads)\n\n### Unix/Linux 🐧\n\nNo additional requirements :)\n\n### MacOS 🍎\n\nNo additional requirements :)\n\n### Windows 🪟\n\nOn Windows platforms, dynamic libraries are linked _against_ the executable, not _into_ the executable as is the case o\nUnix platforms.\n\n⚠️ Important ⚠️\n\nThis means that (on Windows) you will **_Need_** to have the Dart SDK installed and available on your system path to\nbe able to compile Dart-sys.\n\n## Installing 📦\n\nRun the following Cargo command in your project directory:\n\n```bash\ncargo add dart-sys\n```\n\nOr add the following line to your Cargo.toml:\n\n```toml\ndart-sys = \"4.1.5\"\n```\n\n## Usage 💻\n\n### Examples 📚\n\nAn extremely straightforward example of using `dart-sys` would be like such:\n\n```rust\nuse dart_sys::{Dart_Handle, Dart_NewIntegerFromI64};\n\n#[no_mangle]\n/// Adds two integers together.\npub extern \"C\" fn dart_sys_example_extension_sum(\n    a: Dart_Handle,\n    b: Dart_Handle,\n) -\u003e Dart_Handle {\n    let a = unsafe { Dart_NewIntegerFromI64(a) };\n    let b = unsafe { Dart_NewIntegerFromI64(b) };\n    a + b\n}\n\n#[no_mangle]\n/// Multiplies two integers together.\npub extern \"C\" fn dart_sys_example_extension_product(\n    a: Dart_Handle,\n    b: Dart_Handle,\n) -\u003e Dart_Handle {\n    let a = unsafe { Dart_NewIntegerFromI64(a) };\n    let b = unsafe { Dart_NewIntegerFromI64(b) };\n    a * b\n}\n```\n\n```dart\nimport 'dart:ffi';\n\n// open and link to the native library\nfinal DynamicLibrary nativeLib = DynamicLibrary.open('libdart_sys_example_extension.so');\n\n// lookup the sum function in the native library\nfinal int Function(int, int) sum = nativeLib\n    .lookup\u003cNativeFunction\u003cInt32 Function(Int32, Int32)\u003e\u003e('dart_sys_example_extension_sum')\n    .asFunction();\n\n// lookup the product function in the native library\nfinal int Function(int, int) product = nativeLib\n    .lookup\u003cNativeFunction\u003cInt32 Function(Int32, Int32)\u003e\u003e('dart_sys_example_extension_product')\n    .asFunction();\n\nvoid main() {\n    print(sum(1, 2)); // 3\n    print(product(1, 2)); // 2\n}\n```\n\nWhile this example is certainly possible, you are not likely to ever use Dart-sys for this purpose.\nSee the [examples](examples/) directory for more in-depth\nexamples of how to use Dart-sys. All examples are tested using GitHub Actions and documented verbosely.\n\n## Built With 🛠️\n\n- [Rust](https://www.rust-lang.org/) - A systems programming language that runs\n blazingly fast, prevents segfaults, and guarantees thread safety.\n- [Dart](https://dart.dev/) - A client-optimized language for fast apps on any platform.\n- [Dart Native Extensions](https://dart.dev/server/c-interop-native-extensions) - A mechanism\n for writing native code in C/C++ and calling it from Dart.\n- [bindgen](https://crates.io/crates/bindgen) - A Rust library for generating\n bindings to C and C++ APIs.\n\n## Contributing ✏️\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct,\nand the process for submitting pull requests. If you have any questions, please\nopen an issue, or contact admin \u003cgutenfries@gmail.com\u003e directly.\n\n## Versioning 🪧\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available,\nsee the [tags on this repository](https://github.com/dart-sys/dart-sys/tags).\n\n## License 📜\n\nDart-sys is open-sourced and released under the terms and conditions of one or both of the following licenses:\n\n- [MIT License](LICENSE-MIT.md)\n- [Apache License (Version 2.0)](LICENSE-APACHE-2.0.md)\n\n## Acknowledgments 🙏\n\n- [README starter](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2) by [@PurpleBooth](https://gist.github.com/PurpleBooth)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdart-sys%2Fdart-sys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdart-sys%2Fdart-sys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdart-sys%2Fdart-sys/lists"}