{"id":21714743,"url":"https://github.com/shmuelamar/rs-py-java","last_synced_at":"2025-09-09T15:39:11.832Z","repository":{"id":44246400,"uuid":"176338319","full_name":"shmuelamar/rs-py-java","owner":"shmuelamar","description":"Rust FFI example project for Java \u0026 Python","archived":false,"fork":false,"pushed_at":"2019-06-08T11:08:30.000Z","size":12,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T19:14:02.848Z","etag":null,"topics":["ffi","java","python","rust"],"latest_commit_sha":null,"homepage":null,"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/shmuelamar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-18T17:38:23.000Z","updated_at":"2024-05-17T07:44:08.000Z","dependencies_parsed_at":"2022-09-15T13:02:10.100Z","dependency_job_id":null,"html_url":"https://github.com/shmuelamar/rs-py-java","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shmuelamar%2Frs-py-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shmuelamar%2Frs-py-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shmuelamar%2Frs-py-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shmuelamar%2Frs-py-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shmuelamar","download_url":"https://codeload.github.com/shmuelamar/rs-py-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618281,"owners_count":21134201,"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":["ffi","java","python","rust"],"created_at":"2024-11-26T00:38:27.106Z","updated_at":"2025-04-12T19:14:06.801Z","avatar_url":"https://github.com/shmuelamar.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust FFI Example for Java \u0026 Python\n\nExample project for sharing logic between Python \u0026 Java using rust FFI.\n\n## Why?\n\nPython and Java are two popular languages, sometimes we need them to share a common\nlogic, for example calculating some formula or running domain specific algorithm.\n\nFFI has been around for a while but writing C/C++ code considered unsafe, which most of the \ntime is unacceptable on memory managed languages like Python \u0026 Java.\n\nRust comes to the picture with a safe(r) memory management model,\nwith comparable speed to C/C++ that compiles to native shared libraries so we can enjoy both worlds and \nmake Python \u0026 Java friends again (not really :).\n\n\n## Getting Started\n\n### Dependencies\n\n* rustc \u0026 cargo nightly (nightly for PyO3)\n* Python3\n* Java (1.8+ preferred)\n* make (for automating commands)\n\n*tested on ubuntu-18.04 x64*\n\n\nrun these commands:\n\n```bash\n$ make build\n$ make test\n```\n\nnow you can just copy the shared libraries from `dist/` directory\n\n\n## Project Structure\n\nwe got 3 packages on our Cargo workspace:\n\n* **rs-divider** - shared library implementation in rust\n* **rs-divider-java** - java bindings for rs-divider\n* **rs-divider-py** - python bindings for rs-divider\n\n\n## Project Structure:\n\n```\n.\n├── Cargo.lock\n├── Cargo.toml          # our workspace, definition of the 3 packages\n├── dist/               # contains java \u0026 python shared libraries (.so files)\n├── Makefile            # for automating build and test tasks\n├── rs-divider          # our shared rust lib\n│   ├── Cargo.toml\n│   └── src\n│       └── lib.rs      # our shared rust lib source code\n├── rs-divider-java     # java binding to rs-divider\n│   ├── Cargo.toml\n│   ├── RsDivider.h     # auto generated jni header file. contains the function signature for our lib\n│   ├── RsDivider.java  # example main for using our rsdivider lib from java\n│   └── src\n│       └── lib.rs      # src of the wrapper between java and rust using the `jni` crate\n└── rs-divider-py       # python binding to rs-divider\n    ├── Cargo.toml\n    ├── rsdivider.py    # example main for using rsdivider lib from python\n    └── src\n        └── lib.rs      # code using `pyo3` crate for wrapping rs-divider as python shared lib\n```\n\n\n## License\n\nMIT \u0026 APACHE dual license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshmuelamar%2Frs-py-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshmuelamar%2Frs-py-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshmuelamar%2Frs-py-java/lists"}