gdextension_api/4.5/mod.rs
1/*
2 * Copyright (c) godot-rust; Bromeon and contributors.
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
6 */
7
8//! # GDExtension API for Godot 4.5
9
10use std::borrow::Cow;
11
12/// Abstracts from borrow/owned and allows to change implementation without affecting API.
13pub type CowStr = Cow<'static, str>;
14
15/// Version of the Godot engine that the API JSON and C header mirror.
16///
17/// Note that this currently only contains the `major.minor[.patch]` part, so even `4.2-rc1` would be `4.2` (although pre-releases are currently
18/// not published).
19pub const GODOT_VERSION_STRING: &str = "4.5";
20
21/// Returns the contents of the JSON API file `extension_api.json`.
22pub const fn load_extension_api_json() -> CowStr {
23 Cow::Borrowed(include_str!("extension_api.json"))
24}
25
26/// Dynamically fetch a property of this crate.
27pub fn get_package_property(key: &str) -> Option<CowStr> {
28 let value = match key {
29 "godot_version_string" => Cow::Borrowed(GODOT_VERSION_STRING),
30 _ => return None,
31 };
32
33 Some(value)
34}