gdext_gen/features/
mode.rs

1//! Module for the [`Mode`] a `Godot` game using `Rust GDExtension` can be compiled in.
2
3/// Mode to compile the `Godot` game and the `Rust GDExtension` in.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum Mode {
6    /// Debug mode.
7    Debug,
8    /// Release mode.
9    Release,
10    /// Editor mode (for Godot, since it's the same as debug for Rust).
11    Editor,
12}
13
14impl Mode {
15    /// Gets all build [`Mode`]s available.
16    ///
17    /// # Returns
18    ///
19    /// An array with all available [`Mode`]s.
20    pub fn get_modes() -> [Self; 3] {
21        [Self::Debug, Self::Release, Self::Editor]
22    }
23
24    /// Gets the name of the build [`Mode`] used in `Rust` target folders.
25    ///
26    /// # Returns
27    ///
28    /// The name of the build [`Mode`] as is written in the `Rust` target folder.
29    pub fn get_rust_name(&self) -> &'static str {
30        match self {
31            Self::Debug | Self::Editor => "debug",
32            Self::Release => "release",
33        }
34    }
35
36    /// Gets the name of the build [`Mode`] used in `Godot` targets.
37    ///
38    /// # Returns
39    ///
40    /// The name of the build [`Mode`] as is written in the `Godot` target folder.
41    pub fn get_godot_name(&self) -> &'static str {
42        match self {
43            Self::Debug => "debug",
44            Self::Release => "release",
45            Self::Editor => "editor",
46        }
47    }
48}