d3/
lib.rs

1//! A Framework for Server Development
2//! This crate provides a set of tools, for implementing a server. It is especially
3//! well suited for those cases where the server employs a pipeline architecture.
4//! There are two core concepts, the machine, and the instruction set. Combined
5//! with a channel sender and receiver, you have all of the parts necessary for
6//! building a server.
7//!
8//! ## The Machine
9//! The Machine starts with any kind of struct. It becomes a machine by implementing
10//! the Machine trait for an instruction set and joining the collective. There's only
11//! one method that requires implementing. Joining the collective is a single call
12//! into the core, which returns a wrapped machine and a sender for the instruction
13//! set. The machine is the receiver for any instruction sent to that sender. In
14//! most cases the wrapped instance can be ignored.
15//!
16//! ## The Instruction Set
17//! The Instruction Set starts with any kind of enum. It becomes an instruction set
18//! when MachineImpl is derived.
19//!
20//! ## Example
21//!
22//! This example shows how easy it is to create an instruction set, create a machine
23//! and send an instruction to that machine.
24//! ``` text
25//! // A trivial instruction set
26//! #[derive(Debug, MachineImpl)]
27//! enum StateTable { Init, Start, Stop }
28//!
29//! pub struct Alice {}
30//! // implement the Machine trait for Alice
31//! impl Machine<StateTable> for Alice {
32//!     fn receive(&self, cmd: StateTable) {
33//! }
34//!
35//! // create the Machine from Alice, getting back a machine and Sender<StateTable>.
36//! let (alice, sender) = executor::connect(Alice{});
37//!
38//! // send a command to Alice
39//! // Alice's receive method will be called, likely on a different thread than this thread.
40//! sender.send(StateTable::Init).expect("send failed");
41//! ```
42//! The main `d3` crate just re-exports tools from smaller subrates:
43//! ## Derive Macro
44//!
45//! * [`d3-derive`], a derive macro for transforming an enum into an instruction set.
46//!
47//! ## Core
48//!
49//! * [`d3-core`], a sceduler and executor for machines.
50//!
51//!
52//! ## Components
53//!
54//! * [`d3-components`], provides a component/coordinator heirachy of machines.
55//!
56//!
57//! ## Instruction Sets and Test Drivers
58//!
59//! * [`d3-dev-instruction-sets`](https://github.com/BruceBrown/d3/tree/master/d3-dev-instruction-sets/src),
60//! example of some simple instruction sets.
61//! * [`d3-test-driver`](https://github.com/BruceBrown/d3/tree/master/d3-test-drivers/src),
62//!  example of implementing an instruction set. The test driver
63//! is used by bench and test.
64//!
65//! ## Examples
66//!
67//! ### Services
68//! * [`alice-service`](https://github.com/BruceBrown/d3/tree/master/examples/alice-service/src/alice.rs),
69//! an example of a web-service sending a form and processing the POST.
70//! * [`chat-service`](https://github.com/BruceBrown/d3/tree/master/examples/chat-service/src),
71//! an example of a trivial chat service.
72//! * [`echo-service`](https://github.com/BruceBrown/d3/tree/master/examples/echo-service/src),
73//! an example of a trivial echo service.
74//! * [`monitor-service`](https://github.com/BruceBrown/d3/tree/master/examples/monitor-service/src),
75//! an example of service for monitoring the core.
76//!
77//! ### Server
78//! * [`test-server`](https://github.com/BruceBrown/d3/tree/master/examples/test-server/src),
79//! an example of a server running the aforementioned services
80
81// re-publish all the bits, so that you only need d3.
82pub mod d3_derive {
83    pub use d3_derive::*;
84}
85pub mod core {
86    pub mod machine_impl {
87        pub use d3_core::machine_impl::{self, *};
88    }
89    pub mod executor {
90        pub use d3_core::executor::{self, *};
91    }
92    pub use d3_core::send_cmd;
93}
94pub mod components {
95    pub mod network {
96        pub use d3_components::network::{self, *};
97    }
98    pub use d3_components::components::{self, *};
99    pub use d3_components::coordinators::{self, *};
100    pub mod settings {
101        pub use d3_components::settings::{self, *};
102    }
103}