greentic_interfaces/
lib.rs1#![deny(unsafe_code)]
2#![warn(missing_docs, clippy::unwrap_used, clippy::expect_used)]
3#![doc = include_str!("../README.md")]
4
5#[must_use]
9pub fn wit_root() -> std::path::PathBuf {
10 let manifest_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
11 for candidate in [
12 manifest_dir.join("../../wit"),
13 manifest_dir.join("wit"),
14 manifest_dir.join("../greentic-interfaces/wit"),
15 ] {
16 if has_wit_files(&candidate) {
17 return candidate;
18 }
19 }
20 manifest_dir.join("wit")
21}
22
23fn has_wit_files(root: &std::path::Path) -> bool {
24 let mut stack = vec![root.to_path_buf()];
25 while let Some(dir) = stack.pop() {
26 let Ok(entries) = std::fs::read_dir(dir) else {
27 continue;
28 };
29 for entry in entries.flatten() {
30 let path = entry.path();
31 if path.is_dir() {
32 stack.push(path);
33 } else if path.extension().and_then(|s| s.to_str()) == Some("wit") {
34 return true;
35 }
36 }
37 }
38 false
39}
40
41#[cfg(all(feature = "bindings-rust", not(target_arch = "wasm32")))]
43pub mod abi;
44#[cfg(not(target_arch = "wasm32"))]
45pub mod bindings;
46#[cfg(not(target_arch = "wasm32"))]
47pub mod wit_all;
48#[cfg(all(
49 feature = "bindings-rust",
50 feature = "wit-v0_6_0",
51 not(target_arch = "wasm32")
52))]
53pub use abi::canonical;
54#[cfg(all(
55 feature = "bindings-rust",
56 feature = "wit-v0_6_0",
57 not(target_arch = "wasm32")
58))]
59pub use abi::v0_6_0;
60#[cfg(all(
61 feature = "bindings-rust",
62 feature = "provider-common",
63 not(target_arch = "wasm32")
64))]
65pub use bindings::provider_common_0_0_2_common;
66#[cfg(not(target_arch = "wasm32"))]
67#[allow(unused_imports)]
68pub use wit_all::*;
69#[cfg(all(
70 feature = "bindings-rust",
71 feature = "wit-v0_6_0",
72 not(target_arch = "wasm32")
73))]
74pub mod mappers;
75#[cfg(all(
76 feature = "bindings-rust",
77 feature = "wit-v0_6_0",
78 not(target_arch = "wasm32")
79))]
80pub mod validate;