greentic_interfaces/
wit_all.rs

1#![cfg(not(target_arch = "wasm32"))]
2//! Unified Wasmtime bindings for every WIT world shipped with this crate.
3#![allow(clippy::all)]
4#![allow(missing_docs)]
5#![allow(unused_macros)]
6
7macro_rules! declare_world {
8    (
9        mod $mod_name:ident,
10        path = $path_literal:literal,
11        world = $world_literal:literal
12        $(, legacy = { $($legacy:item)* } )?
13    ) => {
14        pub mod $mod_name {
15            mod bindings {
16                wasmtime::component::bindgen!({
17                    path: $path_literal,
18                    world: $world_literal,
19                });
20            }
21
22            #[allow(unused_imports)]
23            pub use bindings::*;
24
25            $(
26                $($legacy)*
27            )?
28        }
29    };
30}
31
32#[cfg(feature = "describe-v1")]
33declare_world!(
34    mod component_describe_v1,
35    path = "wit/greentic/component@1.0.0",
36    world = "greentic:component/component@1.0.0",
37    legacy = {
38        /// Canonical package identifier.
39        pub const PACKAGE_ID: &str = "greentic:component@1.0.0";
40    }
41);
42
43#[cfg(feature = "component-v1")]
44declare_world!(
45    mod component_v1,
46    path = "wit/greentic/component-v1@0.1.0",
47    world = "greentic:component-v1/component-host@0.1.0",
48    legacy = {
49        /// Canonical package identifier.
50        pub const PACKAGE_ID: &str = "greentic:component-v1@0.1.0";
51    }
52);
53
54#[cfg(feature = "component-v0-5")]
55declare_world!(
56    mod component_v0_5,
57    path = "wit/greentic/component@0.5.0",
58    world = "greentic:component/component@0.5.0",
59    legacy = {
60        use anyhow::Result as AnyResult;
61        use wasmtime::component::{Component as WasmtimeComponent, Linker};
62        use wasmtime::StoreContextMut;
63
64        pub use bindings::greentic::component::control::Host as ControlHost;
65
66        /// Registers the Greentic control interface with the provided linker.
67        pub fn add_control_to_linker<T>(
68            linker: &mut Linker<T>,
69            get_host: impl Fn(&mut T) -> &mut (dyn ControlHost + Send + Sync + 'static)
70                + Send
71                + Sync
72                + Copy
73                + 'static,
74        ) -> wasmtime::Result<()>
75        where
76            T: Send + 'static,
77        {
78            let mut inst = linker.instance("greentic:component/control@0.5.0")?;
79
80            inst.func_wrap(
81                "should-cancel",
82                move |mut caller: StoreContextMut<'_, T>, (): ()| {
83                    let host = get_host(caller.data_mut());
84                    let result = host.should_cancel();
85                    Ok((result,))
86                },
87            )?;
88
89            inst.func_wrap(
90                "yield-now",
91                move |mut caller: StoreContextMut<'_, T>, (): ()| {
92                    let host = get_host(caller.data_mut());
93                    host.yield_now();
94                    Ok(())
95                },
96            )?;
97
98            Ok(())
99        }
100
101        /// Back-compat shim for instantiating the component.
102        pub struct Component;
103
104        impl Component {
105            /// Loads the component from raw bytes, mirroring the old helper.
106            pub fn instantiate(
107                engine: &wasmtime::Engine,
108                component_wasm: &[u8],
109            ) -> AnyResult<WasmtimeComponent> {
110                Ok(WasmtimeComponent::from_binary(engine, component_wasm)?)
111            }
112        }
113
114        /// Canonical package identifier.
115        pub const PACKAGE_ID: &str = "greentic:component@0.5.0";
116    }
117);
118
119#[cfg(feature = "component-v0-5")]
120declare_world!(
121    mod component_configurable_v0_5,
122    path = "wit/greentic/component@0.5.0",
123    world = "greentic:component/component-configurable@0.5.0",
124    legacy = {
125        use anyhow::Result as AnyResult;
126        use wasmtime::component::{Component as WasmtimeComponent, Linker};
127        use wasmtime::StoreContextMut;
128
129        pub use bindings::greentic::component::control::Host as ControlHost;
130
131        /// Registers the Greentic control interface with the provided linker.
132        pub fn add_control_to_linker<T>(
133            linker: &mut Linker<T>,
134            get_host: impl Fn(&mut T) -> &mut (dyn ControlHost + Send + Sync + 'static)
135                + Send
136                + Sync
137                + Copy
138                + 'static,
139        ) -> wasmtime::Result<()>
140        where
141            T: Send + 'static,
142        {
143            let mut inst = linker.instance("greentic:component/control@0.5.0")?;
144
145            inst.func_wrap(
146                "should-cancel",
147                move |mut caller: StoreContextMut<'_, T>, (): ()| {
148                    let host = get_host(caller.data_mut());
149                    let result = host.should_cancel();
150                    Ok((result,))
151                },
152            )?;
153
154            inst.func_wrap(
155                "yield-now",
156                move |mut caller: StoreContextMut<'_, T>, (): ()| {
157                    let host = get_host(caller.data_mut());
158                    host.yield_now();
159                    Ok(())
160                },
161            )?;
162
163            Ok(())
164        }
165
166        /// Back-compat shim for instantiating the component.
167        pub struct Component;
168
169        impl Component {
170            /// Loads the component from raw bytes, mirroring the old helper.
171            pub fn instantiate(
172                engine: &wasmtime::Engine,
173                component_wasm: &[u8],
174            ) -> AnyResult<WasmtimeComponent> {
175                Ok(WasmtimeComponent::from_binary(engine, component_wasm)?)
176            }
177        }
178
179        /// Canonical package identifier.
180        pub const PACKAGE_ID: &str = "greentic:component@0.5.0";
181    }
182);
183
184#[cfg(feature = "common-types-v0-1")]
185declare_world!(
186    mod common_types_v0_1,
187    path = "wit/greentic/common-types@0.1.0",
188    world = "greentic:common-types/common@0.1.0",
189    legacy = {
190        /// Canonical package identifier.
191        pub const PACKAGE_ID: &str = "greentic:common-types@0.1.0";
192    }
193);
194
195#[cfg(feature = "component-v0-4")]
196declare_world!(
197    mod component_v0_4,
198    path = "wit/greentic/component@0.4.0",
199    world = "greentic:component/component@0.4.0",
200    legacy = {
201        use anyhow::Result as AnyResult;
202        use wasmtime::component::{Component as WasmtimeComponent, Linker};
203        use wasmtime::StoreContextMut;
204
205        pub use bindings::greentic::component::control::Host as ControlHost;
206
207        /// Registers the Greentic control interface with the provided linker.
208        pub fn add_control_to_linker<T>(
209            linker: &mut Linker<T>,
210            get_host: impl Fn(&mut T) -> &mut (dyn ControlHost + Send + Sync + 'static)
211                + Send
212                + Sync
213                + Copy
214                + 'static,
215        ) -> wasmtime::Result<()>
216        where
217            T: Send + 'static,
218        {
219            let mut inst = linker.instance("greentic:component/control@0.4.0")?;
220
221            inst.func_wrap(
222                "should-cancel",
223                move |mut caller: StoreContextMut<'_, T>, (): ()| {
224                    let host = get_host(caller.data_mut());
225                    let result = host.should_cancel();
226                    Ok((result,))
227                },
228            )?;
229
230            inst.func_wrap(
231                "yield-now",
232                move |mut caller: StoreContextMut<'_, T>, (): ()| {
233                    let host = get_host(caller.data_mut());
234                    host.yield_now();
235                    Ok(())
236                },
237            )?;
238
239            Ok(())
240        }
241
242        /// Back-compat shim for instantiating the component.
243        pub struct Component;
244
245        impl Component {
246            /// Loads the component from raw bytes, mirroring the old helper.
247            pub fn instantiate(
248                engine: &wasmtime::Engine,
249                component_wasm: &[u8],
250            ) -> AnyResult<WasmtimeComponent> {
251                Ok(WasmtimeComponent::from_binary(engine, component_wasm)?)
252            }
253        }
254
255        /// Canonical package identifier.
256        pub const PACKAGE_ID: &str = "greentic:component@0.4.0";
257    }
258);
259
260#[cfg(feature = "pack-export-v0-4")]
261declare_world!(
262    mod pack_export_v0_4,
263    path = "wit/greentic/pack-export@0.4.0",
264    world = "greentic:pack-export/pack-exports@0.4.0",
265    legacy = {
266        /// Canonical package identifier.
267        pub const PACKAGE_ID: &str = "greentic:pack-export@0.4.0";
268    }
269);
270
271#[cfg(feature = "pack-export-v1")]
272declare_world!(
273    mod pack_export_v1,
274    path = "wit/greentic/pack-export-v1@0.1.0",
275    world = "greentic:pack-export-v1/pack-host@0.1.0",
276    legacy = {
277        /// Canonical package identifier.
278        pub const PACKAGE_ID: &str = "greentic:pack-export-v1@0.1.0";
279    }
280);
281
282#[cfg(feature = "pack-validate-v0-1")]
283declare_world!(
284    mod pack_validate_v0_1,
285    path = "wit/greentic/pack-validate@0.1.0",
286    world = "greentic:pack-validate/pack-validator@0.1.0",
287    legacy = {
288        /// Canonical package identifier.
289        pub const PACKAGE_ID: &str = "greentic:pack-validate@0.1.0";
290    }
291);
292
293#[cfg(feature = "provision-v0-1")]
294declare_world!(
295    mod provision_v0_1,
296    path = "wit/greentic/provision@0.1.0",
297    world = "greentic:provision/provision-runner@0.1.0",
298    legacy = {
299        /// Canonical package identifier.
300        pub const PACKAGE_ID: &str = "greentic:provision@0.1.0";
301    }
302);
303
304#[cfg(feature = "types-core-v0-4")]
305declare_world!(
306    mod types_core_v0_4,
307    path = "wit/greentic/types-core@0.4.0",
308    world = "greentic:types-core/core@0.4.0",
309    legacy = {
310        /// Canonical package identifier.
311        pub const PACKAGE_ID: &str = "greentic:types-core@0.4.0";
312    }
313);
314
315#[cfg(feature = "runner-host-v1")]
316declare_world!(
317    mod runner_host_v1,
318    path = "wit/greentic/host@1.0.0",
319    world = "greentic:host/runner-host@1.0.0",
320    legacy = {
321        use std::vec::Vec;
322        use wasmtime::component::Linker;
323        use wasmtime::{Result, StoreContextMut};
324
325        pub use bindings::greentic::host::{http_v1, kv_v1};
326
327        /// Minimal trait hosts implement to satisfy the runner-host imports.
328        pub trait RunnerHost {
329            fn http_request(
330                &mut self,
331                method: String,
332                url: String,
333                headers: Vec<String>,
334                body: Option<Vec<u8>>,
335            ) -> Result<Result<Vec<u8>, String>>;
336
337            fn kv_get(&mut self, ns: String, key: String) -> Result<Option<String>>;
338
339            fn kv_put(&mut self, ns: String, key: String, val: String) -> Result<()>;
340        }
341
342        /// Registers the runner-host interfaces with the provided linker.
343        pub fn add_to_linker<T>(
344            linker: &mut Linker<T>,
345            get_host: impl Fn(&mut T) -> &mut (dyn RunnerHost + Send + Sync + 'static)
346                + Send
347                + Sync
348                + Copy
349                + 'static,
350        ) -> Result<()>
351        where
352            T: Send + 'static,
353        {
354            let mut http = linker.instance("greentic:host/http-v1@1.0.0")?;
355            http.func_wrap(
356                "request",
357                move |mut caller: StoreContextMut<'_, T>,
358                      (method, url, headers, body): (String, String, Vec<String>, Option<Vec<u8>>)| {
359                    let host = get_host(caller.data_mut());
360                    host.http_request(method, url, headers, body)
361                        .map(|res| (res,))
362                },
363            )?;
364
365            let mut kv = linker.instance("greentic:host/kv-v1@1.0.0")?;
366            kv.func_wrap(
367                "get",
368                move |mut caller: StoreContextMut<'_, T>, (ns, key): (String, String)| {
369                    let host = get_host(caller.data_mut());
370                    host.kv_get(ns, key).map(|res| (res,))
371                },
372            )?;
373            kv.func_wrap(
374                "put",
375                move |mut caller: StoreContextMut<'_, T>, (ns, key, val): (String, String, String)| {
376                    let host = get_host(caller.data_mut());
377                    host.kv_put(ns, key, val)
378                },
379            )?;
380
381            Ok(())
382        }
383
384        /// Canonical package identifier.
385        pub const PACKAGE_ID: &str = "greentic:host@1.0.0";
386    }
387);
388
389#[cfg(feature = "pack-export-v0-2")]
390declare_world!(
391    mod pack_export_v0_2,
392    path = "wit/greentic/pack-export@0.2.0",
393    world = "greentic:pack-export/pack-exports@0.2.0",
394    legacy = {
395        /// Canonical package identifier.
396        pub const PACKAGE_ID: &str = "greentic:pack-export@0.2.0";
397    }
398);
399
400#[cfg(feature = "types-core-v0-2")]
401declare_world!(
402    mod types_core_v0_2,
403    path = "wit/greentic/types-core@0.2.0",
404    world = "greentic:types-core/core@0.2.0",
405    legacy = {
406        /// Canonical package identifier.
407        pub const PACKAGE_ID: &str = "greentic:types-core@0.2.0";
408    }
409);
410
411#[cfg(feature = "oauth-broker-v1")]
412declare_world!(
413    mod oauth_broker_v1,
414    path = "wit/greentic/oauth-broker@1.0.0",
415    world = "greentic:oauth-broker/broker@1.0.0",
416    legacy = {
417        /// Canonical package identifier.
418        pub const PACKAGE_ID: &str = "greentic:oauth-broker@1.0.0";
419    }
420);
421
422#[cfg(feature = "oauth-broker-v1")]
423declare_world!(
424    mod oauth_broker_client_v1,
425    path = "wit/greentic/oauth-broker@1.0.0",
426    world = "greentic:oauth-broker/broker-client@1.0.0",
427    legacy = {
428        /// Canonical package identifier.
429        pub const PACKAGE_ID: &str = "greentic:oauth-broker@1.0.0";
430    }
431);
432
433#[cfg(feature = "component-lifecycle-v1")]
434declare_world!(
435    mod component_lifecycle_v1,
436    path = "wit/greentic/lifecycle@1.0.0",
437    world = "greentic:lifecycle/component-lifecycle@1.0.0",
438    legacy = {
439        /// Canonical package identifier.
440        pub const PACKAGE_ID: &str = "greentic:lifecycle@1.0.0";
441    }
442);
443
444#[cfg(feature = "secrets-store-v1")]
445declare_world!(
446    mod secrets_store_v1,
447    path = "wit/greentic/secrets-store@1.0.0",
448    world = "greentic:secrets-store/store@1.0.0",
449    legacy = {
450        /// Canonical package identifier.
451        pub const PACKAGE_ID: &str = "greentic:secrets-store@1.0.0";
452    }
453);
454
455#[cfg(feature = "provider-core-v1")]
456declare_world!(
457    mod provider_schema_core_v1,
458    path = "wit/greentic/provider/schema-core@1.0.0",
459    world = "greentic:provider-schema-core/schema-core@1.0.0",
460    legacy = {
461        /// Canonical package identifier.
462        pub const PACKAGE_ID: &str = "greentic:provider-schema-core@1.0.0";
463    }
464);
465
466#[cfg(feature = "provider-common")]
467declare_world!(
468    mod provider_common,
469    path = "wit/provider-common/world.wit",
470    world = "provider:common/common@0.0.2"
471);
472
473#[cfg(feature = "state-store-v1")]
474declare_world!(
475    mod state_store_v1,
476    path = "wit/greentic/state-store@1.0.0",
477    world = "greentic:state/store@1.0.0",
478    legacy = {
479        pub const PACKAGE_ID: &str = "greentic:state@1.0.0";
480    }
481);
482
483#[cfg(feature = "http-client-v1")]
484declare_world!(
485    mod http_client_v1,
486    path = "wit/greentic/http-client@1.0.0",
487    world = "greentic:http/client@1.0.0",
488    legacy = {
489        pub const PACKAGE_ID: &str = "greentic:http@1.0.0";
490    }
491);
492
493#[cfg(feature = "http-client-v1-1")]
494declare_world!(
495    mod http_client_v1_1,
496    path = "wit/greentic/http-client@1.1.0",
497    world = "greentic:http/client@1.1.0",
498    legacy = {
499        pub const PACKAGE_ID: &str = "greentic:http@1.1.0";
500    }
501);
502
503#[cfg(feature = "telemetry-logger-v1")]
504declare_world!(
505    mod telemetry_logger_v1,
506    path = "wit/greentic/telemetry-logger@1.0.0",
507    world = "greentic:telemetry/logger@1.0.0",
508    legacy = {
509        pub const PACKAGE_ID: &str = "greentic:telemetry@1.0.0";
510    }
511);
512
513#[cfg(feature = "source-v1")]
514declare_world!(
515    mod source_v1,
516    path = "wit/greentic/source@1.0.0",
517    world = "greentic:source/source-sync@1.0.0",
518    legacy = {
519        pub const PACKAGE_ID: &str = "greentic:source@1.0.0";
520    }
521);
522
523#[cfg(feature = "build-v1")]
524declare_world!(
525    mod build_v1,
526    path = "wit/greentic/build@1.0.0",
527    world = "greentic:build/builder@1.0.0",
528    legacy = {
529        pub const PACKAGE_ID: &str = "greentic:build@1.0.0";
530    }
531);
532
533#[cfg(feature = "scan-v1")]
534declare_world!(
535    mod scan_v1,
536    path = "wit/greentic/scan@1.0.0",
537    world = "greentic:scan/scanner@1.0.0",
538    legacy = {
539        pub const PACKAGE_ID: &str = "greentic:scan@1.0.0";
540    }
541);
542
543#[cfg(feature = "signing-v1")]
544declare_world!(
545    mod signing_v1,
546    path = "wit/greentic/signing@1.0.0",
547    world = "greentic:signing/signer@1.0.0",
548    legacy = {
549        pub const PACKAGE_ID: &str = "greentic:signing@1.0.0";
550    }
551);
552
553#[cfg(feature = "attestation-v1")]
554declare_world!(
555    mod attestation_v1,
556    path = "wit/greentic/attestation@1.0.0",
557    world = "greentic:attestation/attester@1.0.0",
558    legacy = {
559        pub const PACKAGE_ID: &str = "greentic:attestation@1.0.0";
560    }
561);
562
563#[cfg(feature = "policy-v1")]
564declare_world!(
565    mod policy_v1,
566    path = "wit/greentic/policy@1.0.0",
567    world = "greentic:policy/policy-evaluator@1.0.0",
568    legacy = {
569        pub const PACKAGE_ID: &str = "greentic:policy@1.0.0";
570    }
571);
572
573#[cfg(feature = "metadata-v1")]
574declare_world!(
575    mod metadata_v1,
576    path = "wit/greentic/metadata@1.0.0",
577    world = "greentic:metadata/metadata-store@1.0.0",
578    legacy = {
579        pub const PACKAGE_ID: &str = "greentic:metadata@1.0.0";
580    }
581);
582
583#[cfg(feature = "distribution-v1")]
584declare_world!(
585    mod distribution_v1,
586    path = "wit/greentic/distribution@1.0.0",
587    world = "greentic:distribution/distribution@1.0.0",
588    legacy = {
589        pub const PACKAGE_ID: &str = "greentic:distribution@1.0.0";
590    }
591);
592
593#[cfg(feature = "distributor-api")]
594declare_world!(
595    mod distributor_api_v1,
596    path = "wit/greentic/distributor@1.0.0",
597    world = "greentic:distributor-api/distributor-api@1.0.0",
598    legacy = {
599        pub const PACKAGE_ID: &str = "greentic:distributor-api@1.0.0";
600    }
601);
602
603#[cfg(feature = "distributor-api-v1-1")]
604declare_world!(
605    mod distributor_api_v1_1,
606    path = "wit/greentic/distributor@1.1.0",
607    world = "greentic:distributor-api/distributor-api@1.1.0",
608    legacy = {
609        pub const PACKAGE_ID: &str = "greentic:distributor-api@1.1.0";
610    }
611);
612
613#[cfg(feature = "oci-v1")]
614declare_world!(
615    mod oci_v1,
616    path = "wit/greentic/oci@1.0.0",
617    world = "greentic:oci/oci-distribution@1.0.0",
618    legacy = {
619        pub const PACKAGE_ID: &str = "greentic:oci@1.0.0";
620    }
621);
622
623#[cfg(feature = "repo-ui-actions-v1")]
624declare_world!(
625    mod repo_ui_actions_repo_ui_worker_v1,
626    path = "wit/greentic/repo-ui-actions@1.0.0",
627    world = "greentic:repo-ui-actions/repo-ui-worker@1.0.0",
628    legacy = {
629        pub const PACKAGE_ID: &str = "greentic:repo-ui-actions@1.0.0";
630    }
631);
632
633#[cfg(feature = "gui-fragment")]
634declare_world!(
635    mod gui_fragment_v1,
636    path = "wit/greentic/gui@1.0.0",
637    world = "greentic:gui/gui-fragment@1.0.0",
638    legacy = {
639        pub const PACKAGE_ID: &str = "greentic:gui@1.0.0";
640    }
641);
642
643#[cfg(feature = "worker-api")]
644declare_world!(
645    mod worker_v1,
646    path = "wit/greentic/worker@1.0.0",
647    world = "greentic:worker/worker@1.0.0",
648    legacy = {
649        pub const PACKAGE_ID: &str = "greentic:worker@1.0.0";
650    }
651);
652
653#[cfg(feature = "wasix-mcp-24-11-05")]
654declare_world!(
655    mod wasix_mcp_24_11_05,
656    path = "wit/wasix-mcp@24.11.05.wit",
657    world = "mcp-router",
658    legacy = {
659        /// Canonical package identifier.
660        pub const PACKAGE_ID: &str = "wasix:mcp@24.11.5";
661    }
662);
663
664#[cfg(feature = "wasix-mcp-25-03-26")]
665declare_world!(
666    mod wasix_mcp_25_03_26,
667    path = "wit/wasix-mcp@25.03.26.wit",
668    world = "mcp-router",
669    legacy = {
670        /// Canonical package identifier.
671        pub const PACKAGE_ID: &str = "wasix:mcp@25.3.26";
672    }
673);
674
675#[cfg(feature = "wasix-mcp-25-06-18")]
676declare_world!(
677    mod wasix_mcp_25_06_18,
678    path = "wit/wasix-mcp@25.06.18.wit",
679    world = "mcp-router",
680    legacy = {
681        /// Canonical package identifier.
682        pub const PACKAGE_ID: &str = "wasix:mcp@25.6.18";
683    }
684);