explaingit

actix/actix

9,198RustAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

Actix is a Rust library for the actor model, where isolated program units communicate only through typed messages, making concurrent applications safer to write without shared memory.

Mindmap

mindmap
  root((actix))
    Core Concepts
      Actors as structs
      Typed messages
      Address objects
    Sending Messages
      send with await
      do_send fire forget
      Recipient interface
    Actor Lifecycle
      started callback
      Supervision
      System shutdown
    Runtime
      Tokio async runtime
      Sync and async actors
      Context timers
    Use Cases
      Concurrent services
      State machines
      Event pipelines
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build a concurrent Rust service where separate actors handle different tasks, like one actor per user session, communicating through typed messages.

USE CASE 2

Model a state machine where each state is an actor that processes messages and transitions to the next state.

USE CASE 3

Implement a processing pipeline where actors in a chain each receive output from the previous stage without sharing memory.

USE CASE 4

Write a simulation where independent entities each run their own logic and react to events from other entities via messages.

Tech stack

RustTokio

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Rust 1.76+ and comfort with Rust's trait system and async/await.

Use freely for any purpose including commercial use, under either MIT or Apache 2.0 at your choice.

In plain English

The actor model is a programming pattern where separate units of a program, called actors, communicate only by sending messages to each other. Each actor processes one message at a time and can hold its own private state, which makes it easier to write programs that do many things at once without the typical pitfalls of shared memory. Actix is a library that brings the actor model to the Rust programming language. You define an actor as a Rust struct, implement a trait that marks it as an actor, then implement message handlers for each type of message you want the actor to receive. Actors run inside a system powered by Tokio, Rust's popular async runtime. This means actors can handle work asynchronously, waiting for things like network responses or timers without blocking other actors. To send a message to an actor, you hold an address object and call send (which awaits a reply) or do_send (which fires and forgets without waiting). Messages are typed, so the compiler checks at build time that you are sending the right kind of data and that the actor's handler returns the expected result type. There is no loosely typed message bag, which is a common shortcut in other actor systems. Actix also supports actor supervision, where a parent actor can monitor a child and decide what to do if the child fails. Both synchronous and asynchronous actors are supported, and actors can schedule delayed actions using context timers. The library requires Rust 1.76 or later and is dual-licensed under MIT and Apache 2.0. Note: the much more widely used actix-web web framework is a separate project that builds on top of this actor foundation. This repository contains the actor model primitives only.

Copy-paste prompts

Prompt 1
I'm using actix in Rust and want two actors to send messages back and forth to each other. Show me how to set up both actors and the cyclic message flow.
Prompt 2
I have an actix actor that accumulates state over time. How do I read a snapshot of that state from outside the actor system, from my main function?
Prompt 3
How do I add a timer inside an actix actor so it sends itself a message every 5 seconds without blocking other message processing?
Prompt 4
I want to use actix supervision so that if a child actor panics, the parent automatically restarts it. Show me how to implement that pattern.
Open on GitHub → Explain another repo

← actix on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.