Quick Start
Build your first Cineyma application in 5 minutes.
Create a New Project
Start by creating a new Rust project:
Add Cineyma and Tokio to your dependencies:
Step 1: Define Your Actor
An actor is a struct that implements the Actor trait. Let's create a simple counter:
Step 2: Define Messages
Messages are how you communicate with actors. Each message has a typed result:
Step 3: Implement Handlers
Handlers define how your actor responds to each message type:
Step 4: Spawn and Use Your Actor
Now let's create the actor system, spawn our actor, and send messages:
Complete Code
Here's the complete example you can copy and run:
Run with cargo run:
Key Concepts
Actor
A struct that holds state and processes messages sequentially. Only one message is processed at a time, eliminating data races.
Message
A typed value sent to an actor. Each message type has an associated Result type for responses.
Handler
Defines how an actor processes a specific message type. The handler has exclusive access to the actor's state.
Address (Addr)
A handle to send messages to an actor. Addresses are cheap to clone and can be shared across tasks.
Context
Provides the actor with access to its own address, the ability to spawn children, schedule timers, and more.
Message Sending Patterns
Cineyma provides three ways to send messages:
Next Steps
You've built your first Cineyma application! Continue learning:
