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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! Cross-node decoder/encoder registry.
//!
//! Each actor type that participates in inter-node delivery contributes
//! one [`InterNodeDecoder`] entry via the `register_for_inter_node!`
//! macro. The receiving node uses the registry to turn incoming envelope
//! bytes back into a concrete `<T as Actor>::Message` (and to encode
//! `Result` bytes for the reply).
//!
//! Built on the [`inventory`](https://docs.rs/inventory) crate; entries
//! are linked into the binary at compile time, so registration must
//! happen at module scope (not inside a function).
use crateActorError;
use Any;
use Arc;
use ;
/// Decoder: raw bytes → `Arc<dyn Any>` carrying a concrete `<T as Actor>::Message`.
/// Built from `decode_codec::<T::Message>` by the registration macro.
pub type DecodeMessageFn =
fn ;
/// Encoder: `Box<dyn Any>` (must downcast to `<T as Actor>::Result`) →
/// raw bytes. Built from `encode_codec::<T::Result>` by the registration
/// macro.
pub type EncodeResultFn =
fn ;
/// Function returning the actor's fully-qualified Rust type name. Stored
/// as a `fn` pointer instead of a `&'static str` because
/// `std::any::type_name` is not a `const fn`.
pub type ActorTypeFn = fn ;
/// One entry in the inter-node decoder/encoder registry.
///
/// One entry per actor type that should be reachable across the cluster.
/// `actor_type` is matched against the `actor_type` field carried in
/// incoming envelopes ([`InterNodeMessage`]); `decode_message` turns the
/// envelope's payload bytes into a typed `Arc<dyn Any>` for
/// `Mailbox::send`/`send_and_recv`; `encode_result` turns the
/// `Box<dyn Any>` returned by `dispatch_local_any_and_recv` back into
/// bytes for the `InterNodeResponse`.
///
/// Use the `register_for_inter_node!` macro to construct + submit
/// entries; never build one by hand.
///
/// [`InterNodeMessage`]: crate::inter_node::InterNodeMessage
collect!;
/// Generic function used by the registration macro to obtain a `fn` pointer
/// that, when called, returns the actor's type name.
///
/// Equivalent to writing `|| std::any::type_name::<T>()`, but as a real
/// `fn` item (so it has a stable function-pointer address) rather than a
/// closure type.
Sized>
/// Look up the decoder for `actor_type` and use it to decode `bytes`
/// into an `Arc<dyn Any>` carrying the concrete message type.
///
/// Returns `InterNodeDecoderMissing` if no `register_for_inter_node!`
/// entry exists for this actor type on this binary; `InterNodeDecode`
/// if the bytes are invalid for the registered type.
/// Look up the encoder for `actor_type` and use it to turn the result
/// `Box<dyn Any>` from `dispatch_local_any_and_recv` back into bytes
/// for the `InterNodeResponse`.
///
/// Returns `InterNodeDecoderMissing` if no entry exists,
/// `MessageTypeMismatch` if the boxed value isn't actually `T::Result`.
/// Helper used by the `register_for_inter_node!` macro.
/// Decodes raw bytes into `Arc<dyn Any>` carrying a concrete `T`.
///
/// You should not call this directly — the macro instantiates it with
/// `T = <YourActor as Actor>::Message` and stores the resulting
/// `fn` pointer in the `InterNodeDecoder` entry.
/// Helper used by the `register_for_inter_node!` macro.
/// Downcasts `Box<dyn Any>` to `T` and encodes via `Codec`.
///
/// You should not call this directly — the macro instantiates it with
/// `T = <YourActor as Actor>::Result` and stores the resulting `fn`
/// pointer in the `InterNodeDecoder` entry.