1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// This file was generated by gir (https://github.com/gtk-rs/gir)
// DO NOT EDIT

use crate::{Iterator};
use glib::{translate::*};

glib::wrapper! {
    #[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct SpaJson(Shared<ffi::WpSpaJson>);

    match fn {
        ref => |ptr| ffi::wp_spa_json_ref(ptr),
        unref => |ptr| ffi::wp_spa_json_unref(ptr),
        type_ => || ffi::wp_spa_json_get_type(),
    }
}

impl SpaJson {
    #[doc(alias = "wp_spa_json_new_boolean")]
    pub fn new_boolean(value: bool) -> SpaJson {
        unsafe {
            from_glib_full(ffi::wp_spa_json_new_boolean(value.into_glib()))
        }
    }

    #[doc(alias = "wp_spa_json_new_float")]
    pub fn new_float(value: f32) -> SpaJson {
        unsafe {
            from_glib_full(ffi::wp_spa_json_new_float(value))
        }
    }

    #[doc(alias = "wp_spa_json_new_int")]
    pub fn new_int(value: i32) -> SpaJson {
        unsafe {
            from_glib_full(ffi::wp_spa_json_new_int(value))
        }
    }

    #[doc(alias = "wp_spa_json_new_null")]
    pub fn new_null() -> SpaJson {
        unsafe {
            from_glib_full(ffi::wp_spa_json_new_null())
        }
    }

    #[doc(alias = "wp_spa_json_new_string")]
    pub fn new_string(value: &str) -> SpaJson {
        unsafe {
            from_glib_full(ffi::wp_spa_json_new_string(value.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_copy")]
#[must_use]
    pub fn copy(&self) -> SpaJson {
        unsafe {
            from_glib_full(ffi::wp_spa_json_copy(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_ensure_unique_owner")]
#[must_use]
    pub fn ensure_unique_owner(self) -> SpaJson {
        unsafe {
            from_glib_full(ffi::wp_spa_json_ensure_unique_owner(self.into_glib_ptr()))
        }
    }

    #[doc(alias = "wp_spa_json_get_size")]
    #[doc(alias = "get_size")]
    pub fn size(&self) -> usize {
        unsafe {
            ffi::wp_spa_json_get_size(self.to_glib_none().0)
        }
    }

    #[doc(alias = "wp_spa_json_is_array")]
    pub fn is_array(&self) -> bool {
        unsafe {
            from_glib(ffi::wp_spa_json_is_array(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_is_boolean")]
    pub fn is_boolean(&self) -> bool {
        unsafe {
            from_glib(ffi::wp_spa_json_is_boolean(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_is_float")]
    pub fn is_float(&self) -> bool {
        unsafe {
            from_glib(ffi::wp_spa_json_is_float(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_is_int")]
    pub fn is_int(&self) -> bool {
        unsafe {
            from_glib(ffi::wp_spa_json_is_int(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_is_null")]
    pub fn is_null(&self) -> bool {
        unsafe {
            from_glib(ffi::wp_spa_json_is_null(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_is_object")]
    pub fn is_object(&self) -> bool {
        unsafe {
            from_glib(ffi::wp_spa_json_is_object(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_is_string")]
    pub fn is_string(&self) -> bool {
        unsafe {
            from_glib(ffi::wp_spa_json_is_string(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_is_unique_owner")]
    pub fn is_unique_owner(&self) -> bool {
        unsafe {
            from_glib(ffi::wp_spa_json_is_unique_owner(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_new_iterator")]
    pub fn new_iterator(&self) -> Iterator {
        unsafe {
            from_glib_full(ffi::wp_spa_json_new_iterator(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_spa_json_parse_boolean")]
    pub fn parse_boolean(&self) -> Option<bool> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::wp_spa_json_parse_boolean(self.to_glib_none().0, value.as_mut_ptr()));
            if ret { Some(from_glib(value.assume_init())) } else { None }
        }
    }

    #[doc(alias = "wp_spa_json_parse_float")]
    pub fn parse_float(&self) -> Option<f32> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::wp_spa_json_parse_float(self.to_glib_none().0, value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "wp_spa_json_parse_int")]
    pub fn parse_int(&self) -> Option<i32> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::wp_spa_json_parse_int(self.to_glib_none().0, value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "wp_spa_json_parse_string")]
    pub fn parse_string(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::wp_spa_json_parse_string(self.to_glib_none().0))
        }
    }
}