libappstream/auto/
functions.rs1use crate::{
7 ffi, BundleKind, Category, Component, ComponentScope, DataIdMatchFlags, MarkupKind,
8 MetadataLocation, RelationCompare, VercmpFlags,
9};
10use glib::translate::*;
11
12#[doc(alias = "as_get_current_distro_component_id")]
13#[doc(alias = "get_current_distro_component_id")]
14pub fn current_distro_component_id() -> Option<glib::GString> {
15 assert_initialized_main_thread!();
16 unsafe { from_glib_full(ffi::as_get_current_distro_component_id()) }
17}
18
19#[doc(alias = "as_get_default_categories")]
20#[doc(alias = "get_default_categories")]
21pub fn default_categories(with_special: bool) -> Vec<Category> {
22 assert_initialized_main_thread!();
23 unsafe {
24 FromGlibPtrContainer::from_glib_container(ffi::as_get_default_categories(
25 with_special.into_glib(),
26 ))
27 }
28}
29
30#[doc(alias = "as_get_default_categories_gi")]
31#[doc(alias = "get_default_categories_gi")]
32pub fn default_categories_gi(with_special: bool) -> Vec<Category> {
33 assert_initialized_main_thread!();
34 unsafe {
35 FromGlibPtrContainer::from_glib_full(ffi::as_get_default_categories_gi(
36 with_special.into_glib(),
37 ))
38 }
39}
40
41#[doc(alias = "as_get_license_name")]
42#[doc(alias = "get_license_name")]
43pub fn license_name(license: &str) -> Option<glib::GString> {
44 assert_initialized_main_thread!();
45 unsafe { from_glib_full(ffi::as_get_license_name(license.to_glib_none().0)) }
46}
47
48#[doc(alias = "as_get_license_url")]
49#[doc(alias = "get_license_url")]
50pub fn license_url(license: &str) -> Option<glib::GString> {
51 assert_initialized_main_thread!();
52 unsafe { from_glib_full(ffi::as_get_license_url(license.to_glib_none().0)) }
53}
54
55#[doc(alias = "as_is_spdx_license_exception_id")]
56pub fn is_spdx_license_exception_id(exception_id: &str) -> bool {
57 assert_initialized_main_thread!();
58 unsafe {
59 from_glib(ffi::as_is_spdx_license_exception_id(
60 exception_id.to_glib_none().0,
61 ))
62 }
63}
64
65#[doc(alias = "as_is_spdx_license_expression")]
66pub fn is_spdx_license_expression(license: &str) -> bool {
67 assert_initialized_main_thread!();
68 unsafe { from_glib(ffi::as_is_spdx_license_expression(license.to_glib_none().0)) }
69}
70
71#[doc(alias = "as_is_spdx_license_id")]
72pub fn is_spdx_license_id(license_id: &str) -> bool {
73 assert_initialized_main_thread!();
74 unsafe { from_glib(ffi::as_is_spdx_license_id(license_id.to_glib_none().0)) }
75}
76
77#[doc(alias = "as_license_is_free_license")]
78pub fn license_is_free_license(license: &str) -> bool {
79 assert_initialized_main_thread!();
80 unsafe { from_glib(ffi::as_license_is_free_license(license.to_glib_none().0)) }
81}
82
83#[doc(alias = "as_license_is_metadata_license")]
84pub fn license_is_metadata_license(license: &str) -> bool {
85 assert_initialized_main_thread!();
86 unsafe {
87 from_glib(ffi::as_license_is_metadata_license(
88 license.to_glib_none().0,
89 ))
90 }
91}
92
93#[doc(alias = "as_license_is_metadata_license_id")]
94pub fn license_is_metadata_license_id(license_id: &str) -> bool {
95 assert_initialized_main_thread!();
96 unsafe {
97 from_glib(ffi::as_license_is_metadata_license_id(
98 license_id.to_glib_none().0,
99 ))
100 }
101}
102
103#[doc(alias = "as_license_to_spdx_id")]
104pub fn license_to_spdx_id(license: &str) -> Option<glib::GString> {
105 assert_initialized_main_thread!();
106 unsafe { from_glib_full(ffi::as_license_to_spdx_id(license.to_glib_none().0)) }
107}
108
109#[doc(alias = "as_markup_convert")]
110pub fn markup_convert(markup: &str, to_kind: MarkupKind) -> Result<glib::GString, glib::Error> {
111 assert_initialized_main_thread!();
112 unsafe {
113 let mut error = std::ptr::null_mut();
114 let ret = ffi::as_markup_convert(markup.to_glib_none().0, to_kind.into_glib(), &mut error);
115 if error.is_null() {
116 Ok(from_glib_full(ret))
117 } else {
118 Err(from_glib_full(error))
119 }
120 }
121}
122
123#[doc(alias = "as_markup_strsplit_words")]
124pub fn markup_strsplit_words(text: &str) -> Vec<glib::GString> {
125 assert_initialized_main_thread!();
126 let line_len = text.len() as _;
127 unsafe {
128 FromGlibPtrContainer::from_glib_full(ffi::as_markup_strsplit_words(
129 text.to_glib_none().0,
130 line_len,
131 ))
132 }
133}
134
135#[doc(alias = "as_spdx_license_tokenize")]
136pub fn spdx_license_tokenize(license: &str) -> Vec<glib::GString> {
137 assert_initialized_main_thread!();
138 unsafe {
139 FromGlibPtrContainer::from_glib_full(ffi::as_spdx_license_tokenize(
140 license.to_glib_none().0,
141 ))
142 }
143}
144
145#[doc(alias = "as_utils_build_data_id")]
146pub fn utils_build_data_id(
147 scope: ComponentScope,
148 bundle_kind: BundleKind,
149 origin: &str,
150 cid: &str,
151 branch: &str,
152) -> Option<glib::GString> {
153 assert_initialized_main_thread!();
154 unsafe {
155 from_glib_full(ffi::as_utils_build_data_id(
156 scope.into_glib(),
157 bundle_kind.into_glib(),
158 origin.to_glib_none().0,
159 cid.to_glib_none().0,
160 branch.to_glib_none().0,
161 ))
162 }
163}
164
165#[doc(alias = "as_utils_data_id_equal")]
166pub fn utils_data_id_equal(data_id1: &str, data_id2: &str) -> bool {
167 assert_initialized_main_thread!();
168 unsafe {
169 from_glib(ffi::as_utils_data_id_equal(
170 data_id1.to_glib_none().0,
171 data_id2.to_glib_none().0,
172 ))
173 }
174}
175
176#[doc(alias = "as_utils_data_id_get_cid")]
177pub fn utils_data_id_get_cid(data_id: &str) -> Option<glib::GString> {
178 assert_initialized_main_thread!();
179 unsafe { from_glib_full(ffi::as_utils_data_id_get_cid(data_id.to_glib_none().0)) }
180}
181
182#[doc(alias = "as_utils_data_id_hash")]
183pub fn utils_data_id_hash(data_id: &str) -> u32 {
184 assert_initialized_main_thread!();
185 unsafe { ffi::as_utils_data_id_hash(data_id.to_glib_none().0) }
186}
187
188#[doc(alias = "as_utils_data_id_match")]
189pub fn utils_data_id_match(data_id1: &str, data_id2: &str, match_flags: DataIdMatchFlags) -> bool {
190 assert_initialized_main_thread!();
191 unsafe {
192 from_glib(ffi::as_utils_data_id_match(
193 data_id1.to_glib_none().0,
194 data_id2.to_glib_none().0,
195 match_flags.into_glib(),
196 ))
197 }
198}
199
200#[doc(alias = "as_utils_data_id_valid")]
201pub fn utils_data_id_valid(data_id: &str) -> bool {
202 assert_initialized_main_thread!();
203 unsafe { from_glib(ffi::as_utils_data_id_valid(data_id.to_glib_none().0)) }
204}
205
206#[doc(alias = "as_utils_get_desktop_environment_name")]
207pub fn utils_get_desktop_environment_name(de_id: &str) -> Option<glib::GString> {
208 assert_initialized_main_thread!();
209 unsafe {
210 from_glib_none(ffi::as_utils_get_desktop_environment_name(
211 de_id.to_glib_none().0,
212 ))
213 }
214}
215
216#[doc(alias = "as_utils_get_gui_environment_style_name")]
217pub fn utils_get_gui_environment_style_name(env_style: &str) -> Option<glib::GString> {
218 assert_initialized_main_thread!();
219 unsafe {
220 from_glib_none(ffi::as_utils_get_gui_environment_style_name(
221 env_style.to_glib_none().0,
222 ))
223 }
224}
225
226#[doc(alias = "as_utils_get_tag_search_weight")]
227pub fn utils_get_tag_search_weight(tag_name: &str) -> u16 {
228 assert_initialized_main_thread!();
229 unsafe { ffi::as_utils_get_tag_search_weight(tag_name.to_glib_none().0) }
230}
231
232#[doc(alias = "as_utils_guess_scope_from_path")]
233pub fn utils_guess_scope_from_path(path: &str) -> ComponentScope {
234 assert_initialized_main_thread!();
235 unsafe { from_glib(ffi::as_utils_guess_scope_from_path(path.to_glib_none().0)) }
236}
237
238#[doc(alias = "as_utils_install_metadata_file")]
239pub fn utils_install_metadata_file(
240 location: MetadataLocation,
241 filename: &str,
242 origin: &str,
243 destdir: &str,
244) -> Result<(), glib::Error> {
245 assert_initialized_main_thread!();
246 unsafe {
247 let mut error = std::ptr::null_mut();
248 let is_ok = ffi::as_utils_install_metadata_file(
249 location.into_glib(),
250 filename.to_glib_none().0,
251 origin.to_glib_none().0,
252 destdir.to_glib_none().0,
253 &mut error,
254 );
255 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
256 if error.is_null() {
257 Ok(())
258 } else {
259 Err(from_glib_full(error))
260 }
261 }
262}
263
264#[doc(alias = "as_utils_is_category_name")]
265pub fn utils_is_category_name(category_name: &str) -> bool {
266 assert_initialized_main_thread!();
267 unsafe {
268 from_glib(ffi::as_utils_is_category_name(
269 category_name.to_glib_none().0,
270 ))
271 }
272}
273
274#[doc(alias = "as_utils_is_desktop_environment")]
275pub fn utils_is_desktop_environment(de_id: &str) -> bool {
276 assert_initialized_main_thread!();
277 unsafe { from_glib(ffi::as_utils_is_desktop_environment(de_id.to_glib_none().0)) }
278}
279
280#[doc(alias = "as_utils_is_gui_environment_style")]
281pub fn utils_is_gui_environment_style(env_style: &str) -> bool {
282 assert_initialized_main_thread!();
283 unsafe {
284 from_glib(ffi::as_utils_is_gui_environment_style(
285 env_style.to_glib_none().0,
286 ))
287 }
288}
289
290#[doc(alias = "as_utils_is_platform_triplet")]
291pub fn utils_is_platform_triplet(triplet: &str) -> bool {
292 assert_initialized_main_thread!();
293 unsafe { from_glib(ffi::as_utils_is_platform_triplet(triplet.to_glib_none().0)) }
294}
295
296#[doc(alias = "as_utils_is_tld")]
297pub fn utils_is_tld(tld: &str) -> bool {
298 assert_initialized_main_thread!();
299 unsafe { from_glib(ffi::as_utils_is_tld(tld.to_glib_none().0)) }
300}
301
302#[doc(alias = "as_utils_locale_is_compatible")]
303pub fn utils_locale_is_compatible(locale1: Option<&str>, locale2: Option<&str>) -> bool {
304 assert_initialized_main_thread!();
305 unsafe {
306 from_glib(ffi::as_utils_locale_is_compatible(
307 locale1.to_glib_none().0,
308 locale2.to_glib_none().0,
309 ))
310 }
311}
312
313#[doc(alias = "as_utils_posix_locale_to_bcp47")]
314pub fn utils_posix_locale_to_bcp47(locale: &str) -> Option<glib::GString> {
315 assert_initialized_main_thread!();
316 unsafe { from_glib_full(ffi::as_utils_posix_locale_to_bcp47(locale.to_glib_none().0)) }
317}
318
319#[doc(alias = "as_utils_sort_components_into_categories")]
320pub fn utils_sort_components_into_categories(
321 cpts: &[Component],
322 categories: &[Category],
323 check_duplicates: bool,
324) {
325 assert_initialized_main_thread!();
326 unsafe {
327 ffi::as_utils_sort_components_into_categories(
328 cpts.to_glib_none().0,
329 categories.to_glib_none().0,
330 check_duplicates.into_glib(),
331 );
332 }
333}
334
335#[doc(alias = "as_vercmp")]
336pub fn vercmp(a: &str, b: &str, flags: VercmpFlags) -> i32 {
337 assert_initialized_main_thread!();
338 unsafe { ffi::as_vercmp(a.to_glib_none().0, b.to_glib_none().0, flags.into_glib()) }
339}
340
341#[doc(alias = "as_vercmp_simple")]
342pub fn vercmp_simple(a: &str, b: &str) -> i32 {
343 assert_initialized_main_thread!();
344 unsafe { ffi::as_vercmp_simple(a.to_glib_none().0, b.to_glib_none().0) }
345}
346
347#[doc(alias = "as_vercmp_test_match")]
348pub fn vercmp_test_match(
349 ver1: &str,
350 compare: RelationCompare,
351 ver2: &str,
352 flags: VercmpFlags,
353) -> bool {
354 assert_initialized_main_thread!();
355 unsafe {
356 from_glib(ffi::as_vercmp_test_match(
357 ver1.to_glib_none().0,
358 compare.into_glib(),
359 ver2.to_glib_none().0,
360 flags.into_glib(),
361 ))
362 }
363}
364
365#[doc(alias = "as_version_string")]
366pub fn version_string() -> Option<glib::GString> {
367 assert_initialized_main_thread!();
368 unsafe { from_glib_none(ffi::as_version_string()) }
369}