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        imports: { default: async | trappable | tracing },
48        with: {
49           "wasi:blobstore/container/container": blobstore::Container,
50           "wasi:blobstore/container/stream-object-names": blobstore::StreamObjectNames,
51           "wasi:blobstore/types/incoming-value": blobstore::IncomingValue,
52           "wasi:blobstore/types/outgoing-value": blobstore::OutgoingValue,
53           "wasi:io": wasmtime_wasi::p2::bindings::io,
54           "wasi:keyvalue/store/bucket": keyvalue::Bucket,
55           "wasmcloud:bus/lattice/call-target-interface": lattice::CallTargetInterface,
56           "wasmcloud:bus/error/error": crate::component::Error,
57           "wasmcloud:messaging/types@0.3.0/client": messaging0_3_0::Client,
58           "wasmcloud:messaging/types@0.3.0/message": messaging0_3_0::Message,
59           "wasmcloud:messaging/request-reply@0.3.0/request-options": messaging0_3_0::RequestOptions,
60           "wasmcloud:secrets/store/secret": secrets::Secret,
61           "wrpc:rpc": wrpc_runtime_wasmtime::bindings::rpc,
62        },
63    });
64}
65
66#[allow(missing_docs)]
67mod unversioned_logging_bindings {
68    wasmtime::component::bindgen!({
69        world: "unversioned-interfaces",
70        imports: { default: async | trappable | tracing },
71    });
72}
73
74#[allow(missing_docs)]
75mod config_legacy {
76    wasmtime::component::bindgen!({
77        path: "wit/config-legacy",
78        world: "wasi:config/imports@0.2.0-draft",
79        imports: { default: async | trappable | tracing },
80    });
81}
82
83#[allow(clippy::doc_markdown)]
84#[allow(missing_docs)]
85/// wRPC interface bindings
86pub mod wrpc {
87    wit_bindgen_wrpc::generate!({
88        path: "wit/wrpc",
89        world: "wrpc-interfaces",
90        with: {
91            "wasi:blobstore/types@0.2.0-draft": wrpc_interface_blobstore::bindings::wasi::blobstore::types,
92            "wrpc:blobstore/types@0.1.0": wrpc_interface_blobstore::bindings::wrpc::blobstore::types,
93        },
94        generate_all,
95    });
96}
97
98/// `wasi:config` bindings
99pub mod config {
100    pub use super::config_legacy::wasi::config::runtime;
101    pub use super::wasmtime_bindings::wasi::config::store;
102}
103
104impl std::fmt::Display for wasmtime_bindings::wasi::logging0_1_0_draft::logging::Level {
105    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
106        write!(
107            f,
108            "{}",
109            match self {
110                Self::Trace => "trace",
111                Self::Debug => "debug",
112                Self::Info => "info",
113                Self::Warn => "warn",
114                Self::Error => "error",
115                Self::Critical => "critical",
116            }
117        )
118    }
119}
120
121pub use unversioned_logging_bindings::wasi::logging as unversioned_logging;
122pub use wasmtime_bindings::wasi::{blobstore, keyvalue, logging0_1_0_draft as logging};
123pub use wasmtime_bindings::wasmcloud::{
124    bus1_0_0, bus2_0_1 as bus, bus2_0_1, identity, messaging0_2_0, messaging0_3_0 as messaging,
125    messaging0_3_0, secrets,
126};
127pub use wasmtime_bindings::Interfaces;
128pub use wasmtime_wasi_http::bindings::http;