{"id":18638572,"url":"https://github.com/takahirox/ecs-rust","last_synced_at":"2026-02-23T16:34:33.378Z","repository":{"id":57623105,"uuid":"346529209","full_name":"takahirox/ecs-rust","owner":"takahirox","description":"Tiny ECS library in Rust","archived":false,"fork":false,"pushed_at":"2021-11-12T06:45:51.000Z","size":3382,"stargazers_count":71,"open_issues_count":2,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-12-13T17:27:51.977Z","etag":null,"topics":["ecs","rust","rust-crate","webassembly"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/takahirox.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}},"created_at":"2021-03-11T00:20:25.000Z","updated_at":"2025-06-07T08:29:37.000Z","dependencies_parsed_at":"2022-08-26T23:51:38.002Z","dependency_job_id":null,"html_url":"https://github.com/takahirox/ecs-rust","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/takahirox/ecs-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takahirox%2Fecs-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takahirox%2Fecs-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takahirox%2Fecs-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takahirox%2Fecs-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takahirox","download_url":"https://codeload.github.com/takahirox/ecs-rust/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takahirox%2Fecs-rust/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29748227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: 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":["ecs","rust","rust-crate","webassembly"],"created_at":"2024-11-07T05:42:29.593Z","updated_at":"2026-02-23T16:34:33.329Z","avatar_url":"https://github.com/takahirox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ecs-rust\n\n[![Build Status](https://travis-ci.org/takahirox/ecs-rust.svg?branch=main)](https://travis-ci.org/takahirox/ecs-rust)\n[![Crate](https://img.shields.io/crates/v/ecs_rust.svg)](https://crates.io/crates/ecs_rust)\n\n`ecu-rust` is a tiny toy [ECS (Entity Component System)](https://en.wikipedia.org/wiki/Entity_component_system) library written in Rust.\n\n## Online demos\n\n[Online WebAssembly demos](https://takahirox.github.io/ecs-rust/web/examples/index.html#canvas)\n\nRust code is compiled to WebAssembly with [wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/) and it runs even in web browsers.\n\n![Web Collision demo](./screenshots/web_collision_demo.gif)\n\n## Features\n\n* Tiny [ECS](https://en.wikipedia.org/wiki/Entity_component_system) library\n* Easy to use\n* Memory safe with Rust\n* Offers a clean design with [ECS](https://en.wikipedia.org/wiki/Entity_component_system)\n* Web application compatible by compiling to WebAssembly\n\n## Documents\n\nT.B.D.\n\n## Sample Code\n\n```Rust\n// Import ecs-rust\nuse ecs_rust::world::World;\nuse ecs_rust::entity_manager::{EntityIdAccessor, EntityManager};\nuse ecs_rust::component::Component;\nuse ecs_rust::system::System;\n\n// Define Components and Systems\n\nstruct Namable {\n  name: \u0026'static str\n}\n\nstruct Position {\n  x: f32,\n  y: f32\n}\n\nstruct Velocity {\n  x: f32,\n  y: f32\n}\n\nstruct Step {\n  num: u32\n}\n\nstruct PrintStepSystem;\nstruct MoveSystem;\nstruct PrintPositionSystem;\n\n// Implement Components and Systems\n\nimpl Component for Namable {}\nimpl Component for Position {}\nimpl Component for Velocity {}\nimpl Component for Step {}\n\nimpl System for PrintStepSystem {\n  fn update(\u0026mut self, manager: \u0026mut EntityManager, _accessor: \u0026mut EntityIdAccessor) {\n    let steps = manager.borrow_components_mut::\u003cStep\u003e().unwrap();\n    for step in steps.iter_mut() {\n      step.num += 1;\n      println!(\"Step {}\", step.num);\n    }\n  }\n}\n\nimpl System for MoveSystem {\n  fn update(\u0026mut self, manager: \u0026mut EntityManager, accessor: \u0026mut EntityIdAccessor) {\n    let entity_ids = accessor.borrow_ids_for_pair::\u003cVelocity, Position\u003e(manager).unwrap();\n    for id in entity_ids.iter() {\n      let (velocity, mut position) = manager.borrow_component_pair_mut::\u003cVelocity, Position\u003e(*id).unwrap();\n      position.x += velocity.x;\n      position.y += velocity.y;\n    }\n  }\n}\n\nimpl System for PrintPositionSystem {\n  fn update(\u0026mut self, manager: \u0026mut EntityManager, accessor: \u0026mut EntityIdAccessor) {\n    let entity_ids = accessor.borrow_ids_for_pair::\u003cNamable, Position\u003e(manager).unwrap();\n    for id in entity_ids.iter() {\n      let name = manager.borrow_component::\u003cNamable\u003e(*id).unwrap();\n      let position = manager.borrow_component::\u003cPosition\u003e(*id).unwrap();\n      println!(\"{} is at ({}, {})\", name.name, position.x, position.y);\n    }\n  }\n}\n\n// Build an application and Run\n\nfn main() {\n  // Create world\n  let mut world = World::new();\n\n  // Register Components to world\n  world\n    .register_component::\u003cStep\u003e()\n    .register_component::\u003cNamable\u003e()\n    .register_component::\u003cPosition\u003e()\n    .register_component::\u003cVelocity\u003e();\n\n  // Create Entities and add Components to them\n  {\n    let entity_id = world.create_entity();\n    world.add_component_to_entity(entity_id, Step {num: 0});\n  }\n\n  {\n    let entity_id = world.create_entity();\n    world\n      .add_component_to_entity(entity_id, Namable {name: \"Alice\"})\n      .add_component_to_entity(entity_id, Position {x: 0.0, y: 0.0})\n      .add_component_to_entity(entity_id, Velocity {x: 1.0, y: 2.0});\n  }\n\n  {\n    let entity_id = world.create_entity();\n    world\n      .add_component_to_entity(entity_id, Namable {name: \"Bob\"})\n      .add_component_to_entity(entity_id, Position {x: 0.0, y: 0.0})\n      .add_component_to_entity(entity_id, Velocity {x: -2.0, y: 1.0});\n  }\n\n  {\n    // Unmovable\n    let entity_id = world.create_entity();\n    world\n      .add_component_to_entity(entity_id, Namable {name: \"Rock\"})\n      .add_component_to_entity(entity_id, Position {x: 0.0, y: 0.0});\n  }\n\n  // Add Systems to world\n  world\n    .add_system(PrintStepSystem {})\n    .add_system(MoveSystem {})\n    .add_system(PrintPositionSystem {});\n\n  // Run\n  for _i in 0..3 {\n    world.update();\n  }\n}\n\n/*\n * Result:\n * Step 1\n * Alice is at (1, 2)\n * Bob is at (-2, 1)\n * Rock is at (0, 0)\n * Step 2\n * Alice is at (2, 4)\n * Bob is at (-4, 2)\n * Rock is at (0, 0)\n * Step 3\n * Alice is at (3, 6)\n * Bob is at (-6, 3)\n * Rock is at (0, 0)\n */\n```\n\n## How to import\n\nThe library is released at [crates.io](https://crates.io/crates/ecs_rust). Add the following line into Cargo.toml of your Rust project.\n\n```\n[dependencies]\necs_rust = \"0.0.4\"\n```\n\nAnd add the following lines in your Rust code to import the library.\n\n```Rust\nuse ecs_rust::world::World;\nuse ecs_rust::entity_manager::{EntityIdAccessor, EntityManager};\nuse ecs_rust::component::Component;\nuse ecs_rust::system::System;\n```\n\n## How to build the library locally\n\n```sh\n$ git clone https://github.com/takahirox/ecs-rust.git\n$ cd ecs-rust\n$ cargo build\n```\n\n## How to run desktop examples locally\n\n```sh\n$ cd ecs-rust\n$ cargo run --example example_name\n```\n\n## How to run web examles locally\n\nPrerequirements\n- Install [wasm-bindgen client](https://rustwasm.github.io/docs/wasm-bindgen/)\n- Install Rust wasm32-unknown-unknown target with `$ rustup target add wasm32-unknown-unknown`\n- Install `http-server` with `$ npm install -g http-server`, or other local servers\n\n```sh\n$ cd ecs-rust/web\n$ bash build_examples.sh\n$ http-server . -p 8080 -c-1\n# Access http://localhost:8080/examples/index.html on your web browser\n```\n\n## How to run tests\n\nT.B.D.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakahirox%2Fecs-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakahirox%2Fecs-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakahirox%2Fecs-rust/lists"}