[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5521":3},{"id":4,"name":5,"fullName":6,"owner":5,"repo":5,"description":7,"homepage":8,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":23,"topics":24,"createdAt":9,"pushedAt":9,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":15,"starSnapshotCount":15,"syncStatus":18,"lastSyncTime":33,"discoverSource":34},5521,"actix","actix\u002Factix","Actor framework for Rust.","",null,"Rust",9216,673,140,33,0,5,22,2,39.49,"Apache License 2.0",false,"main",true,[5,25,26,27,28,29],"actor","actor-model","concurrency","hacktoberfest","rust","2026-06-12 02:01:11","\u003Cdiv align=\"center\">\n  \u003Ch1>Actix\u003C\u002Fh1>\n  \u003Cp>\n    \u003Cstrong>Actor framework for Rust\u003C\u002Fstrong>\n  \u003C\u002Fp>\n  \u003Cp>\n\n\u003C!-- prettier-ignore-start -->\n\n[![crates.io](https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fv\u002Factix?label=latest)](https:\u002F\u002Fcrates.io\u002Fcrates\u002Factix)\n[![Documentation](https:\u002F\u002Fdocs.rs\u002Factix\u002Fbadge.svg?version=0.13.5)](https:\u002F\u002Fdocs.rs\u002Factix\u002F0.13.5)\n![Minimum Supported Rust Version](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Frustc-1.76+-ab6000.svg)\n![License](https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fl\u002Factix.svg)\n[![Dependency Status](https:\u002F\u002Fdeps.rs\u002Fcrate\u002Factix\u002F0.13.5\u002Fstatus.svg)](https:\u002F\u002Fdeps.rs\u002Fcrate\u002Factix\u002F0.13.5)\n\u003Cbr \u002F>\n[![CI](https:\u002F\u002Fgithub.com\u002Factix\u002Factix\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Factix\u002Factix\u002Factions\u002Fworkflows\u002Fci.yml)\n[![codecov](https:\u002F\u002Fcodecov.io\u002Fgh\u002Factix\u002Factix\u002Fbranch\u002Fmain\u002Fgraph\u002Fbadge.svg)](https:\u002F\u002Fcodecov.io\u002Fgh\u002Factix\u002Factix)\n![Downloads](https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fd\u002Factix.svg)\n[![Chat on Discord](https:\u002F\u002Fimg.shields.io\u002Fdiscord\u002F771444961383153695?label=chat&logo=discord)](https:\u002F\u002Fdiscord.gg\u002FGMuKN5b8aR)\n\n\u003C!-- prettier-ignore-end -->\n\n  \u003C\u002Fp>\n\u003C\u002Fdiv>\n\n## Documentation\n\n- [User Guide](https:\u002F\u002Factix.rs\u002Fdocs\u002Factix)\n- [API Documentation](https:\u002F\u002Fdocs.rs\u002Factix)\n\n## Features\n\n- Async and sync actors\n- Actor communication in a local\u002Fthread context\n- Uses [futures](https:\u002F\u002Fcrates.io\u002Fcrates\u002Ffutures) for asynchronous message handling\n- Actor supervision\n- Typed messages (No `Any` type)\n- Runs on stable Rust 1.76+\n\n## Usage\n\nTo use `actix`, add this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nactix = \"0.13\"\n```\n\n### Initialize Actix\n\nIn order to use actix you first need to create a `System`.\n\n```rust,ignore\nfn main() {\n    let system = actix::System::new();\n\n    system.run();\n}\n```\n\nActix uses the [Tokio](https:\u002F\u002Fgithub.com\u002Ftokio-rs\u002Ftokio) runtime. `System::new()` creates a new event loop. `System.run()` starts the Tokio event loop, and will finish once the `System` actor receives the `SystemExit` message.\n\n### Implementing an Actor\n\nIn order to define an actor you need to define a struct and have it implement the [`Actor`](https:\u002F\u002Fdocs.rs\u002Factix\u002Flatest\u002Factix\u002Ftrait.Actor.html) trait.\n\n```rust\nuse actix::{Actor, Context, System};\n\nstruct MyActor;\n\nimpl Actor for MyActor {\n    type Context = Context\u003CSelf>;\n\n    fn started(&mut self, _ctx: &mut Self::Context) {\n        println!(\"I am alive!\");\n        System::current().stop(); \u002F\u002F \u003C- stop system\n    }\n}\n\nfn main() {\n    let system = System::new();\n\n    let _addr = system.block_on(async { MyActor.start() });\n\n    system.run().unwrap();\n}\n```\n\nSpawning a new actor is achieved via the `start` and `create` methods of the [Actor trait]. It provides several different ways of creating actors; for details, check the docs. You can implement the `started`, `stopping` and `stopped` methods of the Actor trait. `started` gets called when the actor starts and `stopping` when the actor finishes. Check the API docs for more information on [the actor lifecycle].\n\n[Actor trait]: https:\u002F\u002Fdocs.rs\u002Factix\u002Flatest\u002Factix\u002Ftrait.Actor.html\n[the actor lifecycle]: https:\u002F\u002Factix.rs\u002Fdocs\u002Factix\u002Factor#actor-lifecycle\n\n### Handle Messages\n\nAn Actor communicates with another Actor by sending messages. In actix all messages are typed. Let's define a simple `Sum` message with two `usize` parameters and an actor which will accept this message and return the sum of those two numbers. Here we use the `#[actix::main]` attribute as an easier way to start our `System` and drive our main function so we can easily `.await` for the responses sent back from the `Actor`.\n\n```rust\nuse actix::prelude::*;\n\n\u002F\u002F this is our Message\n\u002F\u002F we have to define the response type (rtype)\n#[derive(Message)]\n#[rtype(usize)]\nstruct Sum(usize, usize);\n\n\u002F\u002F Actor definition\nstruct Calculator;\n\nimpl Actor for Calculator {\n    type Context = Context\u003CSelf>;\n}\n\n\u002F\u002F now we need to implement `Handler` on `Calculator` for the `Sum` message.\nimpl Handler\u003CSum> for Calculator {\n    type Result = usize; \u002F\u002F \u003C- Message response type\n\n    fn handle(&mut self, msg: Sum, _ctx: &mut Context\u003CSelf>) -> Self::Result {\n        msg.0 + msg.1\n    }\n}\n\n#[actix::main] \u002F\u002F \u003C- starts the system and block until future resolves\nasync fn main() {\n    let addr = Calculator.start();\n    let res = addr.send(Sum(10, 5)).await; \u002F\u002F \u003C- send message and get future for result\n\n    match res {\n        Ok(result) => println!(\"SUM: {}\", result),\n        _ => println!(\"Communication to the actor has failed\"),\n    }\n}\n```\n\nAll communications with actors go through an `Addr` object. You can `do_send` a message without waiting for a response, or you can `send` an actor a specific message. The `Message` trait defines the result type for a message.\n\n### Actor State And Subscription For Specific Messages\n\nYou may have noticed that the methods of the `Actor` and `Handler` traits accept `&mut self`, so you are welcome to store anything in an actor and mutate it whenever necessary.\n\nAddress objects require an actor type, but if we just want to send a specific message to an actor that can handle the message, we can use the `Recipient` interface. Let's create a new actor that uses `Recipient`.\n\n```rust\nuse actix::prelude::*;\nuse std::time::Duration;\n\n#[derive(Message)]\n#[rtype(result = \"()\")]\nstruct Ping {\n    pub id: usize,\n}\n\n\u002F\u002F Actor definition\nstruct Game {\n    counter: usize,\n    name: String,\n    recipient: Recipient\u003CPing>,\n}\n\nimpl Actor for Game {\n    type Context = Context\u003CGame>;\n}\n\n\u002F\u002F simple message handler for Ping message\nimpl Handler\u003CPing> for Game {\n    type Result = ();\n\n    fn handle(&mut self, msg: Ping, ctx: &mut Context\u003CSelf>) {\n        self.counter += 1;\n\n        if self.counter > 10 {\n            System::current().stop();\n        } else {\n            println!(\"[{0}] Ping received {1}\", self.name, msg.id);\n\n            \u002F\u002F wait 100 nanoseconds\n            ctx.run_later(Duration::new(0, 100), move |act, _| {\n                act.recipient.do_send(Ping { id: msg.id + 1 });\n            });\n        }\n    }\n}\n\nfn main() {\n    let system = System::new();\n\n    system.block_on(async {\n        \u002F\u002F To create a cyclic game link, we need to use a different constructor\n        \u002F\u002F method to get access to its recipient before it starts.\n        let _game = Game::create(|ctx| {\n            \u002F\u002F now we can get an address of the first actor and create the second actor\n            let addr = ctx.address();\n\n            let addr2 = Game {\n                counter: 0,\n                name: String::from(\"Game 2\"),\n                recipient: addr.recipient(),\n            }\n            .start();\n\n            \u002F\u002F let's start pings\n            addr2.do_send(Ping { id: 10 });\n\n            \u002F\u002F now we can finally create first actor\n            Game {\n                counter: 0,\n                name: String::from(\"Game 1\"),\n                recipient: addr2.recipient(),\n            }\n        });\n    });\n\n    \u002F\u002F let the actors all run until they've shut themselves down\n    system.run().unwrap();\n}\n```\n\n### Chat Example\n\nSee this [chat example] which shows more comprehensive usage in a networking client\u002Fserver service.\n\n[chat example]: https:\u002F\u002Fgithub.com\u002Factix\u002Fexamples\u002Ftree\u002FHEAD\u002Fwebsockets\u002Fchat-tcp\n\n## Contributing\n\nAll contributions are welcome, if you have a feature request don't hesitate to open an issue!\n\n## License\n\nThis project is licensed under either of\n\n- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n\nat your option.\n\n## Code of Conduct\n\nContribution to the actix repo is organized under the terms of the Contributor Covenant. The Actix team promises to intervene to uphold that code of conduct.\n","Actix 是一个为 Rust 语言设计的 Actor 框架。它支持异步和同步的 Actor，通过 futures 实现异步消息处理，并提供了 Actor 监督机制和类型化的消息传递，避免了使用 `Any` 类型，确保了类型安全。该框架利用 Tokio 作为运行时环境，适用于需要高并发处理能力的应用场景，如构建高性能的网络服务或实时数据处理系统。由于其强大的并发处理能力和良好的社区支持（GitHub 上有超过 9000 颁星），Actix 成为了开发复杂分布式系统的理想选择之一。","2026-06-11 03:03:48","top_language"]