Crates.io | d3-core |
lib.rs | d3-core |
version | 0.1.3 |
source | src |
created_at | 2020-10-17 22:20:09.680091 |
updated_at | 2020-11-13 08:01:49.177954 |
description | A framework for server development -- the core layer |
homepage | https://github.com/BruceBrown/d3 |
repository | https://github.com/BruceBrown/d3/tree/master/d3-core |
max_upload_size | |
id | 301682 |
size | 134,647 |
The core runtime for the d3 framework. d3-core is a companion to d3-derive and d3-components. Combined, they form a framework for server development.
Add this to your Cargo.toml
:
[dependencies]
d3-derive = "0.1.3"
d3-core = "0.1.3"
#[macro_use]
extern crate d3_derive;
use d3_core::machine_impl::*;
use d3_core::executor;
// A trivial instruction set
#[derive(Debug, MachineImpl)]
enum StateTable { Init, Start, Stop }
// A trivial Alice
pub struct Alice {}
// Implement the Machine trait for Alice
impl Machine<StateTable> for Alice {
fn receive(&self, cmd: StateTable) {
}
}
// Start the scheduler and executor.
executor::start_server();
// create the Machine from Alice, getting back a machine and Sender<StateTable>.
let (alice, sender) = executor::connect(Alice{});
// send a command to Alice
// Alice's receive method will be invoked, with cmd of StateTable::Init.
sender.send(StateTable::Init).expect("send failed");
// Stop the scheduler and executor.
executor::stop_server();