Crates.io | sampr |
lib.rs | sampr |
version | 0.1.0 |
source | src |
created_at | 2023-06-26 18:11:57.815213 |
updated_at | 2023-06-26 18:11:57.815213 |
description | A message passing framework using actors |
homepage | https://github.com/bzobl/sampr |
repository | https://github.com/bzobl/sampr |
max_upload_size | |
id | 900531 |
size | 48,242 |
The sampr crate provides a message passing framework inspired by actix. In contrast to the latter sampr uses rust's async/await language feature to deal with futures.
Actors are defined by implementing the Actor
trait for an arbitrary
type. An Actor
can receive and process messages by implementing the
Handler<M>
trait for that specific message. When started, each Actor
runs asynchronously as part of its Context
in a separate
tokio::task
.
Whenever a message is received the respective handler function is
called. As rust does, at the time of writing this, not support async
functions in traits, sampr currently relies on
async_trait.
Stream
s into an actor's context and waiting for it to produce items.Context
, i.e., an .send()
function taking a callback (this can be
achieved already by spawning a task, but needs some syntactic sugar).