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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//! Procedural macros for the workspace `effect` crate.
//!
//! Doc links cannot use the `id_effect::…` prefix here: this crate defines an `effect` function, which
//! shadows the `effect` crate name in rustdoc link resolution.
use TokenStream;
/// Compiles and runs the README examples as doctests.
;
/// Derive macro: structural [`PartialEq`], [`Eq`], and [`Hash`] for Effect.ts-style data types.
///
/// Types implementing these impls automatically satisfy [`id_effect::data::EffectData`] via the
/// blanket implementation in the `effect` crate.
/// Injects `pub _tag: &'static str`, an [`id_effect::match_::HasTag`] impl, and
/// `EFFECT_TAGGED_TAG` on the struct (see generated inherent associated const).
///
/// Only supports structs with **named fields**. Place **above** `#[derive(EffectData, …)]`.
/// **Deprecated no-op** (since 0.3; removed in 0.7): returns the item unchanged.
///
/// Capability keys are no longer generated — use the service type itself in `caps!(Service)`,
/// `Needs::<Service>` and `#[provides(Service)]`. Delete the attribute. (Attribute macros
/// cannot carry `#[deprecated]`, so there is no compiler warning.)
/// Derive [`id_effect::ProviderSpec`] when paired with `#[provides(Capability)]`.
///
/// The service value comes from, in order of precedence:
///
/// - `#[provides(Service, with = <constructor>)]` — `|| expr`, `|deps: &Env| expr` (reads
/// already-built capabilities), or a path such as `Self::build` called with no arguments.
/// This is the recommended form: no `fn new() -> Service` (which trips
/// `clippy::new_ret_no_self`) is needed.
/// - `Self::default()` when the struct derives `Default` (the provider is its own service).
/// - `Self::new()` otherwise.
///
/// Add `#[named("variant")]` for a named variant of the same capability.
///
/// ```ignore
/// #[derive(Clone)]
/// struct Counter(u32);
///
/// #[derive(ProviderSpecDerive)]
/// #[provides(Counter, with = || Counter(42))]
/// struct CounterLive;
/// ```
/// Enum match helper — prefix variant patterns with `EnumPath` for exhaustiveness checking.
///
/// ```ignore
/// match_effect!(Color, value, {
/// Red(n) => n,
/// Green => 0,
/// Blue => 1,
/// })
/// ```
/// Procedural do-notation macro for [`id_effect::Effect`].
///
/// See the `effect` crate documentation for usage.
/// Derive field lenses and enum prisms for [`id_effect_optics`].
/// Derive `id_effect_fsm::Fsm` (initial state + transition table) for a fieldless state enum.
///
/// Use it through the re-export `id_effect_fsm::Fsm`; the generated impl names
/// `::id_effect_fsm` unless overridden with `crate = path`.
///
/// - Container: `#[fsm(event = EventType, initial = Variant, crate = path)]` — `event` is
/// required; `initial` defaults to the first variant.
/// - Variant: `#[fsm(on(Event => Target, ..))]`, repeatable. A bare `Event` resolves to
/// `EventType::Event`; a multi-segment path is used as written.
///
/// Unknown targets, unknown `initial`, data-carrying variants, generic enums, and duplicate
/// `(state, event)` edges are compile errors.
///
/// ```ignore
/// use id_effect_fsm::Fsm;
///
/// #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
/// enum DoorEvent { Open, Close }
///
/// #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Fsm)]
/// #[fsm(event = DoorEvent, initial = Closed)]
/// enum Door {
/// #[fsm(on(Open => Opened))]
/// Closed,
/// #[fsm(on(Close => Closed))]
/// Opened,
/// }
///
/// let mut door = Door::state_machine();
/// door.step(DoorEvent::Open).unwrap();
/// assert_eq!(door.state(), Door::Opened);
/// ```
/// Derive an inherent `schema()` constructor and an [`id_effect::schema::HasSchema`] impl for a
/// struct with named fields (JSON-shaped [`id_effect::schema::Unknown`] wire).
///
/// Rename a field on the wire with `#[schema("wire_name")]`.
///
/// ```
/// use id_effect::Schema;
/// use id_effect::schema::{HasSchema, Unknown};
///
/// #[derive(Clone, Debug, PartialEq, Schema)]
/// struct User {
/// #[schema("user_name")]
/// name: String,
/// age: i64,
/// }
///
/// let wire = User::schema().encode(User { name: "Ada".into(), age: 36 });
/// let back = <User as HasSchema>::schema().decode_unknown(&wire).unwrap();
/// assert_eq!(back.name, "Ada");
/// assert!(matches!(wire, Unknown::Object(_)));
/// ```
/// Deprecated alias of [`macro@Schema`]; expands to exactly the same code.
///
/// Earlier releases also generated a `parser()` method backed by the unpublished `id_effect_parse`
/// crate; that method is gone. Build a text parser with
/// `id_effect_parse::SchemaBridge::parser_for::<T>()` instead.
///
/// Derive macros cannot carry `#[deprecated]`, so the compiler will not warn on use — migrate to
/// `#[derive(Schema)]`. This alias will be removed in a future minor release.
/// Mark a process struct as a remotely spawnable behavior.
///
/// ```ignore
/// #[distributed_behavior("counter")]
/// struct Counter { ... }
/// // Counter::BEHAVIOR_NAME == "counter"
/// // Counter::register_behavior(&mut registry);
/// ```