{"id":13423315,"url":"https://github.com/hominee/crossbus","last_synced_at":"2025-03-15T17:31:40.256Z","repository":{"id":146986913,"uuid":"618439770","full_name":"hominee/crossbus","owner":"hominee","description":"A Platform-less, Runtime-less Actor Computing Model","archived":false,"fork":false,"pushed_at":"2024-03-01T06:55:40.000Z","size":2680,"stargazers_count":122,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T13:17:24.537Z","etag":null,"topics":["actor-model","async","asynchronous","bare-metal","embedded","no-std","platform-less","runtime-less","rust"],"latest_commit_sha":null,"homepage":"https://hominee.github.io/crossbus/","language":"Rust","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/hominee.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":"2023-03-24T13:24:22.000Z","updated_at":"2025-02-11T21:57:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"c796aa1a-84c6-44a4-b77d-6a5150bf6012","html_url":"https://github.com/hominee/crossbus","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/hominee%2Fcrossbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hominee%2Fcrossbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hominee%2Fcrossbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hominee%2Fcrossbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hominee","download_url":"https://codeload.github.com/hominee/crossbus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243766796,"owners_count":20344815,"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":["actor-model","async","asynchronous","bare-metal","embedded","no-std","platform-less","runtime-less","rust"],"created_at":"2024-07-31T00:00:30.392Z","updated_at":"2025-03-15T17:31:39.665Z","avatar_url":"https://github.com/hominee.png","language":"Rust","funding_links":[],"categories":["no-std crates"],"sub_categories":["WIP"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003eCrossBus\u003c/h1\u003e\n  \u003cp\u003e\n    \u003cstrong\u003eA Platform-Less, Runtime-Less Actor Computing Model\u003c/strong\u003e\n  \u003c/p\u003e\n\n  \u003cp\u003e\n\n[![API Document](https://img.shields.io/docsrs/crossbus/latest)](https://docs.rs/crossbus)\n[![crates.io](https://img.shields.io/crates/v/crossbus.svg)](https://crates.io/crates/crossbus)\n\n  \u003c/p\u003e\n\u003c/div\u003e\n\n## Overview\n[CrossBus](https://github.com/hominee/crossbus) is an implementation of\n[Actor Computing Model](https://en.wikipedia.org/wiki/Actor_model), \nwith the concept that \n\n- **Runtime-less**\n\n  crossbus neither provide runtime for app execution \n  nor access the system interface abstraction. \n  no built-in runtime, but any runtime is allowed,  \n  the system-provided / third-party's / that from \n  `FFI`-binding all work.\n  Last but not least, even a bare-bone [noop-waker executor](https://docs.rs/futures-task/latest/futures_task/fn.noop_waker.html)\n  can do.\n\n  runtime-located features like `concurrency`, `network` and `I/O`\n  are up to implementor. \n\n- **Bare-Metal Compatible**\n\n  crossbus links to no system libraries, no libc, \n  and a few upstream libraries\n  enbale you run rust code on bare metal.\n\n  the [examples](https://github.com/hominee/crossbus/tree/master/examples)\n  folder contains some demos to use crossbus. \n\n- **Platform-less by Runtime-less** \n\n  take the advantage of runtime-less, crossbus is able to \n  bypass the limitation of runtime implementor and system \n  interface abstraction and go right straight to manipulate \n  task directly. Only a simple and dummy future executor(look at \n   the [no-std example](https://github.com/hominee/crossbus/tree/master/examples/no-std)) is sufficed to run crossbus. This is the primary \n  concept of crossbus to run across many platforms or \n  without platforms. \n\n- **Future-oriented Routine and Events**\n\n  the futures way to execute task is retained even \n  without runtime thanks to rust. crossbus defines a set of types \n  and traits to allow asynchronous tasks manipulation.\n\n- **Real-time Execution Control**\n\n  taking the advantage of the design of future routine,\n  each poll and events alongside can be intercepted for \n  each spawned task during execution, with which more \n  execution control is possible.\n\n**Currently crossbus is in its alpha version, all APIs and architecture \nis not stable yet, and evolves very quickly.**\n\n## Documentation\n\n- [API Document](https://docs.rs/crossbus)\n\n- [Dev Blog](https://hominee.github.io/crossbus/dev/post/content.html)\n\n- [Manual Book Coming Soon]()\n\n## Feature Flags \nTo reduce code redundancy and speed up compilation, crossbus use feature flag to mark the necessary modules/functions, Currently here are some supported Features:\n\n- `core`/`no-std`: the default feature, bare-metal compatible \n- `std`: rust std library dependent\n- `derive`: enable `#[derive(Message)]` and `#[crossbus::main(...)]`\n- `log`: enable logging out states and infos during runtime\n- `time`: enable Actor to known time when blocking/delaying some duration\n- `rt`: enable use some common convenient runtime \n- `tokio`: convenience to use bare tokio-based runtime \n- `async-std`: convenience to use async-std-based runtime  \n- `wasm32`: convenience to use wasm-bindgen-futures-based runtime \n- `unstable`: marker for unstable feature\n- `time-metric`: enabled with `unstable` and `time`, numerical timing feature \n- `force-poll`: enabled with `unstable`, `time`-dependent to periodically wakeup future polling\n\n## How to Use \nFirst of all, add `crossbus` to `Cargo.toml` of project\n```toml \n[dependencies]\ncrossbus = \"0.0.6-a\"\n```\n#### Types and Imports\n\ndefine Some types and methods according to your business logic.\n\nlet's say a actor to add some number up, \nOkay, then the message should be numbers\nthe actor should know the result after adding.\n```rust\nuse crossbus::prelude::*;\n\nstruct Num(uisze);\nimpl Message for Num {}\n\nstruct CrossBus {\n    sum: isize\n}\n```\n\n#### Actor Implementation\n\nthe actor should be created before using it\n\nwe tell crossbus how to create it\n\n```rust \nimpl Actor for CrossBus {\n    type Message = Num;\n...\n    fn create(ctx: \u0026mut Context\u003cSelf\u003e) -\u003e Self {\n        Self { sum: 0, }\n    }\n...\n}\n\n```\n\n#### Message Action \u0026 Reaction\n\nOkay, How the actor respond when the message comes?\nwe should tell crossbus.\n\n```rust \n    ...\n    fn action(\u0026mut self, msg: Self::Message, ctx: \u0026mut Context\u003cSelf\u003e) {\n        self.sum += msg.0;\n    }\n    ...\n\n```\nSo far so good, but how to obtain the final result \n\nit can be available when the actor process all messages \nand stopped, right? \n\n```rust \n    ...\n    fn stopped(\u0026mut self, _: \u0026mut Context\u003cSelf\u003e) {\n        println!(\"final sum: {}\", self.sum);\n    }\n    ...\n```\n\nDone. Congratulation! You just knew the basic routine to use crossbus.\nthe Full code see below.\n\n## Example\nHere presents a simple demo to sum numbers.\n\nFor more examples, you can go to the [examples](https://github.com/hominee/crossbus/tree/master/examples) folder\nand clone the repo and run them locally.\n\n```rust \nuse crossbus::prelude::*;\n\nstruct Num(uisze);\nimpl Message for Num {}\n\nstruct CrossBus {\n    sum: isize\n}\nimpl Actor for CrossBus {\n    type Message = Num;\n\n    fn create(ctx: \u0026mut Context\u003cSelf\u003e) -\u003e Self {\n        Self { sum: 0, }\n    }\n\n    fn action(\u0026mut self, msg: Self::Message, ctx: \u0026mut Context\u003cSelf\u003e) {\n        self.sum += msg.0;\n    }\n\n    fn stopped(\u0026mut self, _: \u0026mut Context\u003cSelf\u003e) {\n        println!(\"final sum: {}\", self.sum);\n        assert_eq!(self.sum, 7);\n    }\n\n}\n\n#[main(runtime = tokio)]\nasync fn main() {\n    let (addr, id) = CrossBus::start();\n\t\tprintln!(\"actor {} started\", id);\n    let sender = addr.sender();\n    sender.send(Num(1)).unwrap();\n    sender.send(Num(2)).unwrap();\n    sender.send(Num(4)).unwrap();\n}\n```\n\n## Contributing\n\nFeel Free to Contribute! All issues / bugs-report / feature-request / etc\nare welcome!\n\n## References \n\n- [Actix](https://actix.rs)\n- [Yew](https://yew.rs)\n- [Actor Model](https://en.wikipedia.org/wiki/Actor_model)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhominee%2Fcrossbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhominee%2Fcrossbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhominee%2Fcrossbus/lists"}