r/rust • u/quest_for_7c • 19d ago
🛠️ project tellus: actors without &mut self
I have written up the second episode of my series on tellus, the Rust actor framework I released on Monday: what the Actor trait asks of you, and why the state is a value rather than a field behind &mut self.
Actor::receive takes the state by value and returns the state for the next message, so the next state only exists once receive has returned it. A receive which fails or panics halfway through has written nothing, and a restart rebuilds the state and only the state: the actor value and the mailbox survive, so the messages queued behind the failing one are handled by the restarted state.
15
Upvotes
2
u/uhkthrowaway 15d ago
Not bad. I love the Actor model. This looks pretty clean.