{"id":16976673,"url":"https://github.com/viniciuscestarii/ffi-bun-rust","last_synced_at":"2025-03-21T21:23:30.922Z","repository":{"id":246534824,"uuid":"821404063","full_name":"ViniciusCestarii/ffi-bun-rust","owner":"ViniciusCestarii","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-21T17:12:18.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T16:11:18.743Z","etag":null,"topics":["bun","ffi","rust","ts"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ViniciusCestarii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-06-28T13:12:56.000Z","updated_at":"2025-01-20T20:53:48.000Z","dependencies_parsed_at":"2024-08-21T19:14:14.594Z","dependency_job_id":"1587bb54-49ea-440d-9cff-4f03d6595b49","html_url":"https://github.com/ViniciusCestarii/ffi-bun-rust","commit_stats":null,"previous_names":["viniciuscestarii/ffi-bun-rust"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViniciusCestarii%2Fffi-bun-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViniciusCestarii%2Fffi-bun-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViniciusCestarii%2Fffi-bun-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViniciusCestarii%2Fffi-bun-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ViniciusCestarii","download_url":"https://codeload.github.com/ViniciusCestarii/ffi-bun-rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244870376,"owners_count":20523858,"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":["bun","ffi","rust","ts"],"created_at":"2024-10-14T01:26:54.728Z","updated_at":"2025-03-21T21:23:30.902Z","avatar_url":"https://github.com/ViniciusCestarii.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🍞🦀 FFI Bun Rust\n\n## About\nThis project demonstrates how to integrate Rust code, with TypeScript for web applications using bun:ffi module. It showcases how Rust's performance and safety, combined with TypeScript's ease of development, provide a powerful combination for modern web development.\n\n## Features\n- Performance: Rust provides low-level control and performance optimizations, ideal for compute-intensive tasks in web applications.\n\n- Safety: Rust's strong type system and ownership model prevent common bugs such as null pointer dereferences and data races.\n\n- Developer Experience: TypeScript offers a productive environment with type checking and modern JavaScript features, enhancing code quality and maintainability.\n\n## How It Works\n\n1. Compilation: Rust code compiles into native executable binaries tailored for the target platform.\n\n2. Integration: TypeScript imports and interacts with these compiled binaries using bun:ffi module, facilitating seamless functionality within web applications.\n\n## Benchmark Example\nThe project includes a benchmark comparing JavaScript and Rust sorting capabilities:\n\n```ts\nconst bigArray = new Int32Array(Array.from({ length: 1000000 }, () =\u003e Math.floor(Math.random() * 1000000)))\n\nconsole.time(\"Rust Sort time\");\nlib.symbols.sort_array(bigArray.slice(), bigArray.length);\nconsole.timeEnd(\"Rust Sort time\");\n\nconsole.time(\"JS Sort time\");\nbigArray.sort((a, b) =\u003e a - b);\nconsole.timeEnd(\"JS Sort time\");\n```\n\noutput:\n```\n[Rust Sort time]: 56.76ms\n[JS Sort time]: 301.31ms\n```\n\n## Usage\n\nTo run the project:\n\n1. Navigate to the bun project folder:\n\n```sh\ncd src/bun_project\n```\n\n2. Execute the following command to build and run the project:\n\n```sh\nbun run dev\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviniciuscestarii%2Fffi-bun-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviniciuscestarii%2Fffi-bun-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviniciuscestarii%2Fffi-bun-rust/lists"}