shakespeare

Crates.ioshakespeare
lib.rsshakespeare
version0.0.1
sourcesrc
created_at2024-02-26 23:54:22.844925
updated_at2024-04-21 20:52:56.66655
descriptionAn actor framework
homepage
repositoryhttps://github.com/ejmount/shakespeare
max_upload_size
id1154317
size34,098
Ewan Mount (ejmount)

documentation

README

Shakespeare

Version Build release date codecov Licence Downloads

Shakespeare is an actor framework written in Rust that focuses on ergonomics and extensibility while maintaining high performance.

Its most significant features include:

  • Polymorphic actors - actors' interfaces are a first-class consideration in shakespeare, and allowing code to work over dynamically chosen actors is a primary use case.
  • Rich interfaces - a single interface for an actor can support any number of methods with no more boilerplate than the equivalent trait definition.
  • Static validation - the majority of functionality is implemented by procedural macros, minimizing direct runtime overhead and offering more visibility to the optimizer without sacrificing static type checking at any point.
  • Interoperability - linking actors into the wider ecosystem of async code is designed to be easy.

Example

use tokio::sync::mpsc::*;

#[shakespeare::actor]
mod Actor {
    struct ActorState {
        sender: UnboundedSender<usize>,
    }
    #[shakespeare::performance(canonical)]
    impl BasicRole for ActorState {
        fn speak(&mut self, val: usize) {
            self.sender.send(val).unwrap();
        }
    }
}

#[tokio::test]
async fn main() {
    let (sender, mut recv) = tokio::sync::mpsc::unbounded_channel();
    let state = ActorState { sender };
    let shakespeare::ActorSpawn { actor, .. } = ActorState::start(state);
    actor.speak(42).await.expect("Error sending");
    assert_eq!(recv.recv().await.unwrap(), 42);
}

Licence

Licensed under either of Apache Licence, Version 2.0 or MIT licence at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 licence, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 33

cargo fmt