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
//! The engine's **default Rust kernels** — no C++, available in every configuration.
//!
//! There are **deliberately only two**, and both are purely structural with no assumptions about
//! the payload:
//!
//! | Name | What it does | Ports |
//! |---|---|---|
//! | [`PassThrough`] | zero-copy forward (wiring / placeholder) | 1 → 1, any type |
//! | [`Sink`] | consume only, so a branch can terminate itself | 1 → 0, any type |
//!
//! **Why not more.** Kernels like `Scale` / `Sum` / `Zip` / `Filter` would all have to assume the
//! payload is some concrete type such as `i64`, and ADR #6 states plainly that the engine never
//! interprets payloads — putting integer arithmetic into the engine proper contradicts it.
//! Demonstrating engine semantics (reading options, emitting on close, timestamp alignment,
//! advancing bounds, `source_done`) is the job of the 18 built-in C++ kernels in `../cpp/kernels/`
//! and of `examples/`, not of the engine library that gets published. Fan-out needs no kernel
//! either: **one edge can feed several consumers** natively (see §7, the edge model).
//!
//! Both are written with [`crate::Kernel`] and registered through exactly the same vtable as
//! C++ and Python kernels. [`register_defaults`] runs once when the first graph is built, so YAML
//! can refer to them by name with no registration call from the host.
//!
//! The names deliberately carry **no `Kernel` suffix**, to avoid colliding with the built-in C++
//! kernels (`PassThroughKernel` and friends) — the registry is keyed by name, and registering a
//! duplicate is an error.
use Once;
use crate;
use crate;
use crateResult;
/// Zero-copy forward: hands input 0 straight to output 0, reusing the same payload.
///
/// Registered as **`PassThrough`**. Accepts any payload type; useful for wiring, placeholders and
/// tests.
;
/// A terminal sink: consumes packets and produces nothing (no output ports), so a branch can
/// terminate itself instead of requiring the host to poll it.
///
/// Registered as **`Sink`**. It reports through the engine log rather than stdout — a library
/// should not commandeer the host's output — and bumps the **per-graph** counters
/// `sink.packets` / `sink.closed`, which tests can assert on directly.
/// Register every default Rust kernel. **Idempotent**, and called automatically by
/// [`crate::Graph::from_config`].
///
/// A registration failure — which can only mean the host already registered a kernel of its own
/// under the same name — is silently ignored. The host's kernel wins; the engine should not fail
/// graph construction just to install one of its own.