1use core::ffi::{CStr, c_char, c_int};
4
5pub use crate::properties::SDL_PropertyType as PropertyType;
6
7#[derive(Clone, Copy)]
9pub struct Hint {
10 pub module: &'static str,
11 pub name: &'static str,
12 pub short_name: &'static str,
13 pub value: *const c_char,
14 pub doc: Option<&'static str>,
15 pub available_since: Option<c_int>,
16}
17
18unsafe impl Send for Hint {}
19unsafe impl Sync for Hint {}
20
21impl Hint {
22 #[inline(always)]
23 pub const fn value_cstr(&self) -> &'static CStr {
24 unsafe { CStr::from_ptr(self.value) }
25 }
26
27 #[inline(always)]
28 pub const fn value_str(&self) -> &'static str {
29 match self.value_cstr().to_str() {
30 Ok(str) => str,
31 Err(_) => unreachable!(),
32 }
33 }
34}
35
36#[derive(Clone, Copy)]
38pub struct Property {
39 pub module: &'static str,
40 pub name: &'static str,
41 pub short_name: &'static str,
42 pub value: *const c_char,
43 pub ty: PropertyType,
44 pub doc: Option<&'static str>,
45 pub available_since: Option<c_int>,
46}
47
48unsafe impl Send for Property {}
49unsafe impl Sync for Property {}
50
51impl Property {
52 #[inline(always)]
53 pub const fn value_cstr(&self) -> &'static CStr {
54 unsafe { CStr::from_ptr(self.value) }
55 }
56
57 #[inline(always)]
58 pub const fn value_str(&self) -> &'static str {
59 match self.value_cstr().to_str() {
60 Ok(str) => str,
61 Err(_) => unreachable!(),
62 }
63 }
64}
65
66pub trait GroupMetadata: 'static + Sized {
68 const GROUP_METADATA: &'static Group;
70}
71
72#[non_exhaustive]
73#[derive(Clone, Copy)]
74pub enum GroupKind {
75 Enum,
76 Flags,
77 Id,
78 Lock,
79}
80
81#[derive(Clone, Copy)]
83pub struct Group {
84 pub kind: GroupKind,
85 pub module: &'static str,
86 pub name: &'static str,
87 pub short_name: &'static str,
88 pub doc: Option<&'static str>,
89 pub values: &'static [GroupValue],
90 pub available_since: Option<c_int>,
91}
92
93#[derive(Clone, Copy)]
95pub struct GroupValue {
96 pub name: &'static str,
97 pub short_name: &'static str,
98 pub doc: Option<&'static str>,
99 pub available_since: Option<c_int>,
100}
101
102#[cfg(feature = "metadata")]
103mod generated;
104
105#[cfg(feature = "metadata")]
106#[allow(unused_imports)] pub use generated::*;