{"id":15493513,"url":"https://github.com/sinclairzx81/crimson-rust","last_synced_at":"2025-10-15T02:16:28.407Z","repository":{"id":66034982,"uuid":"140875586","full_name":"sinclairzx81/crimson-rust","owner":"sinclairzx81","description":"CSP experiments in the rust programming language","archived":false,"fork":false,"pushed_at":"2018-08-05T05:29:26.000Z","size":15,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T11:12:36.726Z","etag":null,"topics":["concurrency","csp","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/sinclairzx81.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","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":"2018-07-13T17:32:57.000Z","updated_at":"2023-01-27T06:04:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"81abe6eb-3eba-45c0-ba79-93bccdb78ea4","html_url":"https://github.com/sinclairzx81/crimson-rust","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"8ab88fd6d7223144b78312a8267d32db1b5543b6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fcrimson-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fcrimson-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fcrimson-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fcrimson-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinclairzx81","download_url":"https://codeload.github.com/sinclairzx81/crimson-rust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246068263,"owners_count":20718501,"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":["concurrency","csp","rust"],"created_at":"2024-10-02T08:07:39.854Z","updated_at":"2025-10-15T02:16:23.353Z","avatar_url":"https://github.com/sinclairzx81.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crimson-rust\n\nCSP experiments in the rust programming language.\n\n```rust\nmod crimson;\n\nuse crimson::{ System, Actor, Sender, Receiver };\n\ntype Message = \u0026'static str;\n\nstruct A;\nimpl Actor\u003cMessage\u003e for A {\n  fn run(self, sender: Sender\u003cMessage\u003e, _: Receiver\u003cMessage\u003e) {\n    sender.send(\"B\", \"Hello\").unwrap();\n    sender.send(\"B\", \"World\").unwrap();\n  }\n}\n\nstruct B { count: usize }\nimpl Actor\u003cMessage\u003e for B {\n  fn run(mut self, _: Sender\u003cMessage\u003e, receiver: Receiver\u003cMessage\u003e) {\n    for message in receiver {\n      println!(\"{}: {}\", self.count, message)\n      self.count += 1;\n    }\n  }\n}\n\nfn main() {\n  let mut system = System::new();\n  system.mount(\"A\", Box::new(A));\n  system.mount(\"B\", Box::new(B {count: 0}));\n  system.run(|info| println!(\"{:?}\", info));\n}\n```\n\n### overview\n\ncrimson-rust is a small experiment to test various concurrency abstractions over the top of rusts mpsc channels with a particular focus on `csp` - communicating sequential processes. This library offers a simple host (referred to as a `system`) with the processes themselves referred to as `actors`. This library allows one to host a number of actors within a larger system, and allow actors to communicate with each other across a common back plane (handled by the system in which they are hosted)\n\nAdditionally, this library provides some hooks to explore emergent actor network topologies by having the `system` emit `from -\u003e to` message routing information to the caller (available on `info` above). This information can be used to construct actor dependency graphs, with `from -\u003e to` representative of an edge within the graph, the actors being the nodes. Potentially useful for inspecting and debugging a large actor system.\n\nThe code for this library is offered as is for anyone who finds it useful or interesting.\n\n\n### send\n\nA call to `.send(address)` will result in a message being dispatched to ONE actor at the given `address` in a round robin fashion.\n\n```rust\nstruct A;\nimpl Actor\u003cu32\u003e for A {\n  fn run(self, sender: Sender\u003cu32\u003e, _: Receiver\u003cu32\u003e) {\n    sender.send(\"B\", 1).unwrap(); // to -\u003e B[0]\n    sender.send(\"B\", 1).unwrap(); // to -\u003e B[1]\n    sender.send(\"B\", 1).unwrap(); // to -\u003e B[2]\n  }\n}\n...\nsystem.mount(\"B\", Box::new(B)); // B[0]\nsystem.mount(\"B\", Box::new(B)); // B[1]\nsystem.mount(\"B\", Box::new(B)); // B[2]\n```\n\n```\n                   +------+\n            +---+  |      |\n          +-| m |-\u003e| B[0] |  \n          | +---+  |      |\n          |        +------+\n          |                   \n+------+  |        +------+\n|      |  |        |      |\n| A[n] |--+        | B[1] |  # sent to \"one\" actor (round-robin)\n|      |           |      |\n+------+           +------+\n                             \n                   +------+\n                   |      |\n                   | B[2] |\n                   |      |\n                   +------+\n```\n\n### publish\n\nA call to `.publish(address)` will result in a message being dispatched to ALL actors sharing that `address`.\n\n```rust\nstruct A;\nimpl Actor\u003cu32\u003e for A {\n  fn run(\u0026mut self, sender: Sender\u003cu32\u003e, _: Receiver\u003cu32\u003e) {\n    sender.publish(\"B\", 1).unwrap(); // to -\u003e [B[0], B[1], B[2]]\n  }\n}\n...\nsystem.mount(\"B\", Box::new(B)); // B[0]\nsystem.mount(\"B\", Box::new(B)); // B[1]\nsystem.mount(\"B\", Box::new(B)); // B[2]\n```\n\n```\n                   +------+\n            +---+  |      |\n          +-| m |-\u003e| B[0] |  \n          | +---+  |      |\n          |        +------+\n          |                   \n+------+  |        +------+\n|      |  | +---+  |      |\n| A[n] |--+-| m |-\u003e| B[1] |  # published to \"all\" actors (fan-out)\n|      |  | +---+  |      |\n+------+  |        +------+\n          |                  \n          |        +------+\n          | +---+  |      |\n          +-| m |-\u003e| B[2] |\n            +---+  |      |\n                   +------+\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fcrimson-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinclairzx81%2Fcrimson-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fcrimson-rust/lists"}