Skip to main content

fidius_guest/
wasm_descriptor.rs

1// Copyright 2026 Colliery, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Compile-time descriptor of a fidius interface used by the WASM loader.
16//!
17//! Like [`crate::python_descriptor`], a WASM component has no host-readable
18//! vtable, so the host needs an out-of-band hint: which exported interface the
19//! component implements, the method names in declaration (vtable) order with
20//! their wire mode, and the expected interface hash. The `#[plugin_interface]`
21//! macro emits this (Phase 3); for Phase 2 it is hand-authored alongside the
22//! reference WIT.
23
24/// Static descriptor for one fidius interface, consumed by the WASM loader to
25/// validate and dispatch into a component.
26#[derive(Debug, Clone, Copy)]
27pub struct WasmInterfaceDescriptor {
28    /// Trait name, for diagnostics.
29    pub interface_name: &'static str,
30    /// Fully-qualified exported interface the component must provide, e.g.
31    /// `"fidius:greeter/greeter@1.0.0"`. The host navigates to this interface's
32    /// exports to dispatch methods.
33    pub interface_export: &'static str,
34    /// Same hash the cdylib path bakes into its `PluginDescriptor`. The
35    /// component's `fidius-interface-hash` export must return this.
36    pub interface_hash: u64,
37    /// Methods in declaration order — index here lines up with the cdylib
38    /// vtable index for the same trait.
39    pub methods: &'static [WasmMethodDesc],
40}
41
42/// One method on the interface.
43#[derive(Debug, Clone, Copy)]
44pub struct WasmMethodDesc {
45    /// Export name within the interface (e.g. `"greet"`).
46    pub name: &'static str,
47    /// Whether this method uses raw byte-passthrough wire mode (`#[wire(raw)]`).
48    pub wire_raw: bool,
49}