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
use Any;
use Debug;
/// Opaque, serde-free carrier for a token value attached to a
/// [`NetEvent::TokenAdded`](crate::net_event::NetEvent::TokenAdded) or
/// [`NetEvent::TokenRemoved`](crate::net_event::NetEvent::TokenRemoved) event.
///
/// `libpetri-event` has no serde dependency, so this trait deliberately avoids
/// any serialization contract. Debug-side consumers (`libpetri-debug`) project
/// a `TokenPayload` into `serde_json::Value` via a type-id projector registry.
///
/// # Usage
///
/// - Executors wrap the in-flight token as `Arc<dyn TokenPayload>` at emit
/// time and attach it to the `token` field on `TokenAdded` / `TokenRemoved`.
/// The `Option` on that field lets production paths stay `None` when the
/// `EventStore` has opted out of token capture
/// (`EventStore::CAPTURES_TOKENS = false`).
/// - Debug consumers call [`value_any`](Self::value_any) to downcast to the
/// inner value type and project it via a registered
/// `TokenProjectorRegistry` entry.
///
/// # Why a custom trait and not `Any`
///
/// `Any` alone loses the original type name after erasure — `dyn Any` can be
/// downcast but cannot answer "what type was I?". Archive consumers need the
/// type string for display and for projector lookup, so this trait requires
/// implementers to carry it explicitly.