Commit efb997f
committed
feat(host): implement Registerable for MultiUseSandbox
The primary entry point for registering host functions is the
UninitializedSandbox — that's the lifecycle phase where the guest
hasn't yet been allowed to issue host calls, so the registry can be
populated safely up front.
There are, however, cases where a MultiUseSandbox is obtained
without traversing the Uninitialized → evolve() path:
- Sandboxes loaded from a persisted snapshot.
- Any future API that yields a MultiUseSandbox directly.
In those cases the caller never had a chance to call
register_host_function on an UninitializedSandbox. Today they have
to drop down to internal fields or fork the registry manually.
Extend the Registerable trait impl to MultiUseSandbox so late
registration is a one-liner. Semantics are unchanged: the guest's
dispatcher resolves host functions by name at call time, so
inserting into the registry after evolve() is safe as long as the
first host-call happens after registration completes.
Also flips MultiUseSandbox.host_funcs from pub(super) to pub(crate)
so the impl in src/func/host_functions.rs can reach it.
Signed-off-by: danbugs <danilochiarlone@gmail.com>1 parent b45b363 commit efb997f
2 files changed
Lines changed: 41 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 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 | + | |
59 | 99 | | |
60 | 100 | | |
61 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
0 commit comments