gdextension_api/versions/4.5/src/
lib.rs1use std::borrow::Cow;
14
15pub type CowStr = Cow<'static, str>;
17
18pub const GODOT_VERSION_STRING: &str = "4.5";
23
24#[non_exhaustive]
31pub enum TargetPlatform {
32 Windows,
33 MacOS,
35 Linux,
37 Wasm,
38}
39
40pub const fn load_gdextension_header_h() -> CowStr {
42 CowStr::Borrowed(include_str!("../../4.5/res/gdextension_interface.h"))
43}
44
45#[deprecated = "Wrongly dispatches based on host and doesn't support Wasm. Use load_gdextension_header_rs_for_platform() instead."]
47pub const fn load_gdextension_header_rs() -> CowStr {
48 #[cfg(windows)]
49 let s = include_str!("../../4.5/res/gdextension_interface_windows.rs");
50
51 #[cfg(target_os = "macos")]
52 let s = include_str!("../../4.5/res/gdextension_interface_macos.rs");
53
54 #[cfg(all(unix, not(target_os = "macos")))]
55 let s = include_str!("../../4.5/res/gdextension_interface_linux.rs");
56
57 CowStr::Borrowed(s)
58}
59
60pub fn load_gdextension_header_rs_for_platform(platform: TargetPlatform) -> CowStr {
62 let s = match platform {
63 TargetPlatform::Windows => include_str!("../../4.5/res/gdextension_interface_windows.rs"),
64 TargetPlatform::MacOS => include_str!("../../4.5/res/gdextension_interface_macos.rs"),
65 TargetPlatform::Linux => include_str!("../../4.5/res/gdextension_interface_linux.rs"),
66 TargetPlatform::Wasm => include_str!("../../4.5/res/gdextension_interface_wasm.rs"),
67 };
68
69 CowStr::Borrowed(s)
70}
71
72pub const fn load_gdextension_json() -> CowStr {
74 Cow::Borrowed(include_str!("../res/extension_api.json"))
75}
76
77pub fn get_package_property(key: &str) -> Option<CowStr> {
79 let value = match key {
80 "godot_version_string" => Cow::Borrowed(GODOT_VERSION_STRING),
81 "rust_version_string" => Cow::Borrowed("1.93.0"),
82 "bindgen_version_string" => Cow::Borrowed("0.72.1"),
83 _ => return None,
84 };
85
86 Some(value)
87}