{"id":24631046,"url":"https://github.com/yunusemredilber/rust-runtime-package-system-example","last_synced_at":"2025-07-19T14:34:38.095Z","repository":{"id":192133448,"uuid":"683438843","full_name":"yunusemredilber/rust-runtime-package-system-example","owner":"yunusemredilber","description":"A simple example of a dylib based runtime rust to rust ffi system (dynamic arguments \u0026 return value)","archived":false,"fork":false,"pushed_at":"2023-09-02T05:24:29.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T05:44:00.379Z","etag":null,"topics":["dylib","dynamic","package","runtime","rust","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yunusemredilber.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}},"created_at":"2023-08-26T15:22:43.000Z","updated_at":"2023-09-01T19:26:53.000Z","dependencies_parsed_at":"2023-09-02T20:29:02.340Z","dependency_job_id":null,"html_url":"https://github.com/yunusemredilber/rust-runtime-package-system-example","commit_stats":null,"previous_names":["yunusemredilber/rust-runtime-package-system-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yunusemredilber/rust-runtime-package-system-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunusemredilber%2Frust-runtime-package-system-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunusemredilber%2Frust-runtime-package-system-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunusemredilber%2Frust-runtime-package-system-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunusemredilber%2Frust-runtime-package-system-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yunusemredilber","download_url":"https://codeload.github.com/yunusemredilber/rust-runtime-package-system-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunusemredilber%2Frust-runtime-package-system-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265947508,"owners_count":23853382,"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":["dylib","dynamic","package","runtime","rust","rust-lang"],"created_at":"2025-01-25T07:14:24.057Z","updated_at":"2025-07-19T14:34:38.074Z","avatar_url":"https://github.com/yunusemredilber.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example: Rust Runtime Package System\n\nThis is a straightforward example illustrating a runtime Rust-to-Rust FFI system that relies on dynamic libraries (dylibs).\n\n\u003e This package aims to provide an example of achieving dynamism through FFI (Foreign Function Interface).\n\u003e It does not cover aspects like package metadata, path resolution, compression, mutability, etc.\n\n## Usage\n\n### 1. Building the Test Package\n\nThis system assumes that you can create your packages just like regular cdylib crates.\nSince it follows the usual crate structure, you can build it using Cargo as follows:\n\n```bash\ncd core-package\ncargo build\ncd ..\n```\n\nThis command will generate the `libcore_package.dylib` file inside the `core-package/target/debug/` directory, which we can later use for FFI.\n\nThe example exposes two functions:\n- `add_numbers(args: *mut FFIValue, len: size_t) -\u003e FFIValue`\n- `print(args: *mut FFIValue, len: size_t) -\u003e FFIValue`\n\nTo verify if these functions are accessible, you can use the `nm` utility:\n\n```bash\nnm core-package/target/debug/libcore_package.dylib | grep \"print\"\n# 0000000000004840 T _print\n```\n\nThis output indicates that the `print` function is accessible at runtime.\n\n### 2. Consuming The Package\n\nOnce we have built the example package, we can run the consumer as follows:\n\n```bash\ncd package-consumer\ncargo run\n# hey\n```\n\nThis command will invoke our package's `print` function.\n\n## How it Works\n\nCreating numerous function signatures and mapping them at runtime is not practical.\nThis system takes a more dynamic approach by sending an array of enums (`FFIValue`).\nThe `FFIValue` enum contains basic data types like `f64`, `bool`, and `char`.\nThe library implementer can consume the array of values to obtain arguments.\n\n\u003e Note: The `FFIValue` enum must be consistent in both the library and the consumer. Optionally, these two crates can obtain `FFIValue` from a separate crate.\n\n--\n\n\u003e Author: Yunus Emre Dilber ([@yunusemredilber](https://github.com/yunusemredilber))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyunusemredilber%2Frust-runtime-package-system-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyunusemredilber%2Frust-runtime-package-system-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyunusemredilber%2Frust-runtime-package-system-example/lists"}