1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Imports from Fluxion that are needed for this example
use ;
/// # [`TestActor`]`
/// A unit struct that serves as our test actor.
/// Fluxion doesn't actually care what type you use as an actor.
/// You can use a unit struct like this, a regular struct, tuple struct, or an enum.
/// You can even use generics, and as long as they satisfy [`Send`] + [`Sync`] + `'static` then they will work.
///
/// All that actors require is that the `Actor` trait be implemented for them
/// Unless you define custom initialization or deinitialization logic for your actor,
/// the following macro should be used. Otherwise, the [`fluxion::Actor`] trait must
/// be manually implemented.
;
/// # [`TestMessage`]
/// A unit struct that serves as out test message.
/// Just like with actors, messages can be any type.
/// They just need to satisfy [`Send`] + [`Sync`] + `'static`
/// If the `serde` feature is enabled, messages that wish to be able to be sent to foreign actors,
/// as well as use the [`Fluxion::get`] method, must implemment `Serialize` and `Deserialize`.
/// Actors that do not implement these traits can still be accessed with [`Fluxion::get_local`].
///
/// Optionally, the message's response type may be provided. The actor's ID may also be provided.
/// Here we use the full syntax, but it can be reduced to simply `#[message]`, and the effect will be the same.
/// The default response type is `()` and the default ID for a message is it's full module path.
;
// Message handlers are also pretty simple
// Fluxion requires async to run.
// We just use tokio here, as it is the most popular option.
// Fluxion is completely executor agnostic, so you can use async_std, smol, or even write your own executor.
// Additionally, Fluxion is no_std compatible. All that is required is that you provide an allocator,
// and that you call into Fluxion from an async function.
async