Skip to content

static value types via KnownValueType + single-param unwrap#19

Merged
colinrozzi merged 1 commit into
mainfrom
static-value-types-via-knownvaluetype-single-param
May 10, 2026
Merged

static value types via KnownValueType + single-param unwrap#19
colinrozzi merged 1 commit into
mainfrom
static-value-types-via-knownvaluetype-single-param

Conversation

@colinrozzi
Copy link
Copy Markdown
Owner

static value types via KnownValueType + single-param unwrap

Two related fixes for typed actor state in Theater.

KnownValueType trait: provides ValueType at the type level, so empty
containers (Vec, Option, BTreeSet, BTreeMap, [T; N], Result) carry
correct elem_type / inner_type info even when the value is empty.
Previously From<Vec> inferred elem_type from the items and defaulted
to S32 for empty Vecs, so an empty list field encoded as
list and theater's host-side type validator rejected it.

GraphValue derive emits KnownValueType impls for structs (Record),
tuple structs (Tuple), unit structs (Unit), and variants (Variant).
Pack's host-side PackType collapses to a blanket impl over Into

  • KnownValueType, removing two parallel trait hierarchies.

Export macro single-param unwrap: a guest function with one typed
parameter (e.g. fn list(state: RouterState) -> ...) was decoding the
incoming value directly via try_into(). But theater always wraps inputs
as Tuple([...args]), so the wasm side received Tuple([state]) and
failed with 'failed to convert parameter'. The state-mode and
multi-param branches already unwrapped the wrapping tuple; the
single-param branch now does too.

Two related fixes for typed actor state in Theater.

KnownValueType trait: provides ValueType at the type level, so empty
containers (Vec, Option, BTreeSet, BTreeMap, [T; N], Result) carry
correct elem_type / inner_type info even when the value is empty.
Previously From<Vec<T>> inferred elem_type from the items and defaulted
to S32 for empty Vecs, so an empty list<binding> field encoded as
list<s32> and theater's host-side type validator rejected it.

GraphValue derive emits KnownValueType impls for structs (Record),
tuple structs (Tuple), unit structs (Unit), and variants (Variant).
Pack's host-side PackType collapses to a blanket impl over Into<Value>
+ KnownValueType, removing two parallel trait hierarchies.

Export macro single-param unwrap: a guest function with one typed
parameter (e.g. fn list(state: RouterState) -> ...) was decoding the
incoming value directly via try_into(). But theater always wraps inputs
as Tuple([...args]), so the wasm side received Tuple([state]) and
failed with 'failed to convert parameter'. The state-mode and
multi-param branches already unwrapped the wrapping tuple; the
single-param branch now does too.
@colinrozzi colinrozzi force-pushed the static-value-types-via-knownvaluetype-single-param branch from 112c806 to 4f94dcb Compare May 10, 2026 15:40
@colinrozzi colinrozzi merged commit 43b4493 into main May 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant