wasmcloud_runtime/
capability.rs

1pub use wasmcloud_core::CallTargetInterface;
2
3#[allow(clippy::doc_markdown)]
4#[allow(missing_docs)]
5mod wasmtime_bindings {
6    mod blobstore {
7        pub type Container = std::sync::Arc<str>;
8        pub type IncomingValue = crate::component::blobstore::IncomingValue;
9        pub type OutgoingValue = crate::component::blobstore::OutgoingValue;
10        pub type StreamObjectNames = crate::component::blobstore::StreamObjectNames;
11    }
12
13    mod keyvalue {
14        pub type Bucket = std::sync::Arc<str>;
15    }
16
17    mod lattice {
18        pub type CallTargetInterface = std::sync::Arc<wasmcloud_core::CallTargetInterface>;
19    }
20
21    mod messaging0_3_0 {
22        pub type Message = crate::component::messaging::v0_3::Message;
23        pub type RequestOptions = crate::component::messaging::v0_3::RequestOptions;
24        pub type Client = Box<dyn crate::component::messaging::v0_3::Client + Send + Sync>;
25    }
26
27    mod secrets {
28        use super::wasmcloud::secrets::store::SecretValue;
29
30        pub type Secret = std::sync::Arc<String>;
31
32        impl secrecy::zeroize::Zeroize for SecretValue {
33            fn zeroize(&mut self) {
34                match self {
35                    SecretValue::String(s) => s.zeroize(),
36                    SecretValue::Bytes(b) => b.zeroize(),
37                }
38            }
39        }
40
41        /// Permits cloning
42        impl secrecy::CloneableSecret for SecretValue {}
43    }
44
45    wasmtime::component::bindgen!({
46        world: "interfaces",
47        async: true,
48        tracing: true,
49        trappable_imports: true,
50        with: {
51           "wasi:blobstore/container/container": blobstore::Container,
52           "wasi:blobstore/container/stream-object-names": blobstore::StreamObjectNames,
53           "wasi:blobstore/types/incoming-value": blobstore::IncomingValue,
54           "wasi:blobstore/types/outgoing-value": blobstore::OutgoingValue,
55           "wasi:io": wasmtime_wasi::bindings::io,
56           "wasi:keyvalue/store/bucket": keyvalue::Bucket,
57           "wasmcloud:bus/lattice/call-target-interface": lattice::CallTargetInterface,
58           "wasmcloud:messaging/types@0.3.0/client": messaging0_3_0::Client,
59           "wasmcloud:messaging/types@0.3.0/message": messaging0_3_0::Message,
60           "wasmcloud:messaging/request-reply@0.3.0/request-options": messaging0_3_0::RequestOptions,
61           "wasmcloud:secrets/store/secret": secrets::Secret,
62        },
63    });
64}
65
66#[allow(missing_docs)]
67mod unversioned_logging_bindings {
68    wasmtime::component::bindgen!({
69        world: "unversioned-interfaces",
70        async: true,
71        tracing: true,
72        trappable_imports: true,
73    });
74}
75
76#[allow(missing_docs)]
77mod config_legacy {
78    wasmtime::component::bindgen!({
79        path: "wit/config-legacy",
80        world: "wasi:config/imports@0.2.0-draft",
81        async: true,
82        tracing: true,
83        trappable_imports: true,
84    });
85}
86
87#[allow(clippy::doc_markdown)]
88#[allow(missing_docs)]
89/// wRPC interface bindings
90pub mod wrpc {
91    wit_bindgen_wrpc::generate!({
92        world: "wrpc-interfaces",
93        with: {
94            "wasi:blobstore/types@0.2.0-draft": wrpc_interface_blobstore::bindings::wasi::blobstore::types,
95            "wrpc:blobstore/types@0.1.0": wrpc_interface_blobstore::bindings::wrpc::blobstore::types,
96        },
97        generate_all,
98    });
99}
100
101/// `wasi:config` bindings
102pub mod config {
103    pub use super::config_legacy::wasi::config::runtime;
104    pub use super::wasmtime_bindings::wasi::config::store;
105}
106
107impl std::fmt::Display for wasmtime_bindings::wasi::logging0_1_0_draft::logging::Level {
108    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
109        write!(
110            f,
111            "{}",
112            match self {
113                Self::Trace => "trace",
114                Self::Debug => "debug",
115                Self::Info => "info",
116                Self::Warn => "warn",
117                Self::Error => "error",
118                Self::Critical => "critical",
119            }
120        )
121    }
122}
123
124pub use unversioned_logging_bindings::wasi::logging as unversioned_logging;
125pub use wasmtime_bindings::wasi::{blobstore, keyvalue, logging0_1_0_draft as logging};
126pub use wasmtime_bindings::wasmcloud::{
127    bus1_0_0, bus2_0_0 as bus, bus2_0_0, identity, messaging0_2_0, messaging0_3_0 as messaging,
128    messaging0_3_0, secrets,
129};
130pub use wasmtime_bindings::Interfaces;
131pub use wasmtime_wasi_http::bindings::http;