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
//! Worker-side actor trait.
use Serialize;
use DeserializeOwned;
use Future;
use crateCancellationToken;
use crateContext;
/// Trait for a worker-side actor that processes typed commands.
///
/// # Lifecycle
///
/// 1. The worker starts and calls `run_actor_loop(MyActor::default())`
/// 2. The main thread sends an `Init` payload via `WorkerHandle::send_init()`
/// 3. The actor's `init()` method is called with the payload
/// 4. The command loop begins — all subsequent messages are `Cmd`
///
/// # Type Parameters
///
/// - `Init`: one-time initialization payload. Use `()` for no init.
/// - `Cmd`: The command type posted from Main → Worker.
/// - `Evt`: The event type posted from Worker → Main.