glib/auto/
functions.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "v2_66")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
7use crate::FileSetContentsFlags;
8use crate::{
9    ffi, translate::*, Bytes, ChecksumType, Error, FileTest, FormatSizeFlags, Pid, Source,
10    SpawnFlags, UserDirectory,
11};
12use std::boxed::Box as Box_;
13
14#[doc(alias = "g_access")]
15pub fn access(filename: impl AsRef<std::path::Path>, mode: i32) -> i32 {
16    unsafe { ffi::g_access(filename.as_ref().to_glib_none().0, mode) }
17}
18
19#[doc(alias = "g_base64_decode")]
20pub fn base64_decode(text: &str) -> Vec<u8> {
21    unsafe {
22        let mut out_len = std::mem::MaybeUninit::uninit();
23        let ret = FromGlibContainer::from_glib_full_num(
24            ffi::g_base64_decode(text.to_glib_none().0, out_len.as_mut_ptr()),
25            out_len.assume_init() as _,
26        );
27        ret
28    }
29}
30
31//#[doc(alias = "g_base64_decode_inplace")]
32//pub fn base64_decode_inplace(text: /*Unimplemented*/Vec<u8>) -> u8 {
33//    unsafe { TODO: call ffi:g_base64_decode_inplace() }
34//}
35
36//#[doc(alias = "g_base64_decode_step")]
37//pub fn base64_decode_step(in_: &[u8], out: Vec<u8>, state: &mut i32, save: &mut u32) -> usize {
38//    unsafe { TODO: call ffi:g_base64_decode_step() }
39//}
40
41#[doc(alias = "g_base64_encode")]
42pub fn base64_encode(data: &[u8]) -> crate::GString {
43    let len = data.len() as _;
44    unsafe { from_glib_full(ffi::g_base64_encode(data.to_glib_none().0, len)) }
45}
46
47//#[doc(alias = "g_base64_encode_close")]
48//pub fn base64_encode_close(break_lines: bool, out: Vec<u8>, state: &mut i32, save: &mut i32) -> usize {
49//    unsafe { TODO: call ffi:g_base64_encode_close() }
50//}
51
52//#[doc(alias = "g_base64_encode_step")]
53//pub fn base64_encode_step(in_: &[u8], break_lines: bool, out: Vec<u8>, state: &mut i32, save: &mut i32) -> usize {
54//    unsafe { TODO: call ffi:g_base64_encode_step() }
55//}
56
57#[doc(alias = "glib_check_version")]
58pub fn check_version(
59    required_major: u32,
60    required_minor: u32,
61    required_micro: u32,
62) -> Option<crate::GString> {
63    unsafe {
64        from_glib_none(ffi::glib_check_version(
65            required_major,
66            required_minor,
67            required_micro,
68        ))
69    }
70}
71
72#[doc(alias = "g_compute_checksum_for_bytes")]
73pub fn compute_checksum_for_bytes(
74    checksum_type: ChecksumType,
75    data: &Bytes,
76) -> Option<crate::GString> {
77    unsafe {
78        from_glib_full(ffi::g_compute_checksum_for_bytes(
79            checksum_type.into_glib(),
80            data.to_glib_none().0,
81        ))
82    }
83}
84
85#[doc(alias = "g_compute_checksum_for_data")]
86pub fn compute_checksum_for_data(
87    checksum_type: ChecksumType,
88    data: &[u8],
89) -> Option<crate::GString> {
90    let length = data.len() as _;
91    unsafe {
92        from_glib_full(ffi::g_compute_checksum_for_data(
93            checksum_type.into_glib(),
94            data.to_glib_none().0,
95            length,
96        ))
97    }
98}
99
100#[doc(alias = "g_compute_hmac_for_bytes")]
101pub fn compute_hmac_for_bytes(
102    digest_type: ChecksumType,
103    key: &Bytes,
104    data: &Bytes,
105) -> crate::GString {
106    unsafe {
107        from_glib_full(ffi::g_compute_hmac_for_bytes(
108            digest_type.into_glib(),
109            key.to_glib_none().0,
110            data.to_glib_none().0,
111        ))
112    }
113}
114
115#[doc(alias = "g_compute_hmac_for_data")]
116pub fn compute_hmac_for_data(digest_type: ChecksumType, key: &[u8], data: &[u8]) -> crate::GString {
117    let key_len = key.len() as _;
118    let length = data.len() as _;
119    unsafe {
120        from_glib_full(ffi::g_compute_hmac_for_data(
121            digest_type.into_glib(),
122            key.to_glib_none().0,
123            key_len,
124            data.to_glib_none().0,
125            length,
126        ))
127    }
128}
129
130#[doc(alias = "g_dcgettext")]
131pub fn dcgettext(domain: Option<&str>, msgid: &str, category: i32) -> crate::GString {
132    unsafe {
133        from_glib_none(ffi::g_dcgettext(
134            domain.to_glib_none().0,
135            msgid.to_glib_none().0,
136            category,
137        ))
138    }
139}
140
141#[doc(alias = "g_dgettext")]
142pub fn dgettext(domain: Option<&str>, msgid: &str) -> crate::GString {
143    unsafe {
144        from_glib_none(ffi::g_dgettext(
145            domain.to_glib_none().0,
146            msgid.to_glib_none().0,
147        ))
148    }
149}
150
151#[doc(alias = "g_dngettext")]
152pub fn dngettext(
153    domain: Option<&str>,
154    msgid: &str,
155    msgid_plural: &str,
156    n: libc::c_ulong,
157) -> crate::GString {
158    unsafe {
159        from_glib_none(ffi::g_dngettext(
160            domain.to_glib_none().0,
161            msgid.to_glib_none().0,
162            msgid_plural.to_glib_none().0,
163            n,
164        ))
165    }
166}
167
168#[doc(alias = "g_dpgettext")]
169pub fn dpgettext(domain: Option<&str>, msgctxtid: &str, msgidoffset: usize) -> crate::GString {
170    unsafe {
171        from_glib_none(ffi::g_dpgettext(
172            domain.to_glib_none().0,
173            msgctxtid.to_glib_none().0,
174            msgidoffset,
175        ))
176    }
177}
178
179#[doc(alias = "g_dpgettext2")]
180pub fn dpgettext2(domain: Option<&str>, context: &str, msgid: &str) -> crate::GString {
181    unsafe {
182        from_glib_none(ffi::g_dpgettext2(
183            domain.to_glib_none().0,
184            context.to_glib_none().0,
185            msgid.to_glib_none().0,
186        ))
187    }
188}
189
190#[doc(alias = "g_file_set_contents")]
191pub fn file_set_contents(
192    filename: impl AsRef<std::path::Path>,
193    contents: &[u8],
194) -> Result<(), crate::Error> {
195    let length = contents.len() as _;
196    unsafe {
197        let mut error = std::ptr::null_mut();
198        let is_ok = ffi::g_file_set_contents(
199            filename.as_ref().to_glib_none().0,
200            contents.to_glib_none().0,
201            length,
202            &mut error,
203        );
204        debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
205        if error.is_null() {
206            Ok(())
207        } else {
208            Err(from_glib_full(error))
209        }
210    }
211}
212
213#[cfg(feature = "v2_66")]
214#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
215#[doc(alias = "g_file_set_contents_full")]
216pub fn file_set_contents_full(
217    filename: impl AsRef<std::path::Path>,
218    contents: &[u8],
219    flags: FileSetContentsFlags,
220    mode: i32,
221) -> Result<(), crate::Error> {
222    let length = contents.len() as _;
223    unsafe {
224        let mut error = std::ptr::null_mut();
225        let is_ok = ffi::g_file_set_contents_full(
226            filename.as_ref().to_glib_none().0,
227            contents.to_glib_none().0,
228            length,
229            flags.into_glib(),
230            mode,
231            &mut error,
232        );
233        debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
234        if error.is_null() {
235            Ok(())
236        } else {
237            Err(from_glib_full(error))
238        }
239    }
240}
241
242#[doc(alias = "g_file_test")]
243#[allow(dead_code)]
244pub(crate) fn file_test(filename: impl AsRef<std::path::Path>, test: FileTest) -> bool {
245    unsafe {
246        from_glib(ffi::g_file_test(
247            filename.as_ref().to_glib_none().0,
248            test.into_glib(),
249        ))
250    }
251}
252
253#[doc(alias = "g_filename_display_basename")]
254pub fn filename_display_basename(filename: impl AsRef<std::path::Path>) -> crate::GString {
255    unsafe {
256        from_glib_full(ffi::g_filename_display_basename(
257            filename.as_ref().to_glib_none().0,
258        ))
259    }
260}
261
262#[doc(alias = "g_filename_display_name")]
263pub fn filename_display_name(filename: impl AsRef<std::path::Path>) -> crate::GString {
264    unsafe {
265        from_glib_full(ffi::g_filename_display_name(
266            filename.as_ref().to_glib_none().0,
267        ))
268    }
269}
270
271#[doc(alias = "g_filename_from_uri")]
272pub fn filename_from_uri(
273    uri: &str,
274) -> Result<(std::path::PathBuf, Option<crate::GString>), crate::Error> {
275    unsafe {
276        let mut hostname = std::ptr::null_mut();
277        let mut error = std::ptr::null_mut();
278        let ret = ffi::g_filename_from_uri(uri.to_glib_none().0, &mut hostname, &mut error);
279        if error.is_null() {
280            Ok((from_glib_full(ret), from_glib_full(hostname)))
281        } else {
282            Err(from_glib_full(error))
283        }
284    }
285}
286
287#[doc(alias = "g_filename_to_uri")]
288pub fn filename_to_uri(
289    filename: impl AsRef<std::path::Path>,
290    hostname: Option<&str>,
291) -> Result<crate::GString, crate::Error> {
292    unsafe {
293        let mut error = std::ptr::null_mut();
294        let ret = ffi::g_filename_to_uri(
295            filename.as_ref().to_glib_none().0,
296            hostname.to_glib_none().0,
297            &mut error,
298        );
299        if error.is_null() {
300            Ok(from_glib_full(ret))
301        } else {
302            Err(from_glib_full(error))
303        }
304    }
305}
306
307#[doc(alias = "g_find_program_in_path")]
308pub fn find_program_in_path(program: impl AsRef<std::path::Path>) -> Option<std::path::PathBuf> {
309    unsafe {
310        from_glib_full(ffi::g_find_program_in_path(
311            program.as_ref().to_glib_none().0,
312        ))
313    }
314}
315
316#[doc(alias = "g_format_size")]
317pub fn format_size(size: u64) -> crate::GString {
318    unsafe { from_glib_full(ffi::g_format_size(size)) }
319}
320
321#[doc(alias = "g_format_size_full")]
322pub fn format_size_full(size: u64, flags: FormatSizeFlags) -> crate::GString {
323    unsafe { from_glib_full(ffi::g_format_size_full(size, flags.into_glib())) }
324}
325
326#[doc(alias = "g_get_application_name")]
327#[doc(alias = "get_application_name")]
328pub fn application_name() -> Option<crate::GString> {
329    unsafe { from_glib_none(ffi::g_get_application_name()) }
330}
331
332#[doc(alias = "g_get_codeset")]
333#[doc(alias = "get_codeset")]
334pub fn codeset() -> crate::GString {
335    unsafe { from_glib_full(ffi::g_get_codeset()) }
336}
337
338#[cfg(feature = "v2_62")]
339#[cfg_attr(docsrs, doc(cfg(feature = "v2_62")))]
340#[doc(alias = "g_get_console_charset")]
341#[doc(alias = "get_console_charset")]
342pub fn console_charset() -> Option<crate::GString> {
343    unsafe {
344        let mut charset = std::ptr::null();
345        let ret = from_glib(ffi::g_get_console_charset(&mut charset));
346        if ret {
347            Some(from_glib_none(charset))
348        } else {
349            None
350        }
351    }
352}
353
354#[doc(alias = "g_get_current_dir")]
355#[doc(alias = "get_current_dir")]
356pub fn current_dir() -> std::path::PathBuf {
357    unsafe { from_glib_full(ffi::g_get_current_dir()) }
358}
359
360#[doc(alias = "g_get_environ")]
361#[doc(alias = "get_environ")]
362pub fn environ() -> Vec<std::ffi::OsString> {
363    unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_get_environ()) }
364}
365
366#[doc(alias = "g_get_home_dir")]
367#[doc(alias = "get_home_dir")]
368pub fn home_dir() -> std::path::PathBuf {
369    unsafe { from_glib_none(ffi::g_get_home_dir()) }
370}
371
372#[doc(alias = "g_get_host_name")]
373#[doc(alias = "get_host_name")]
374pub fn host_name() -> crate::GString {
375    unsafe { from_glib_none(ffi::g_get_host_name()) }
376}
377
378#[doc(alias = "g_get_language_names")]
379#[doc(alias = "get_language_names")]
380pub fn language_names() -> Vec<crate::GString> {
381    unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_get_language_names()) }
382}
383
384#[cfg(feature = "v2_58")]
385#[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
386#[doc(alias = "g_get_language_names_with_category")]
387#[doc(alias = "get_language_names_with_category")]
388pub fn language_names_with_category(category_name: &str) -> Vec<crate::GString> {
389    unsafe {
390        FromGlibPtrContainer::from_glib_none(ffi::g_get_language_names_with_category(
391            category_name.to_glib_none().0,
392        ))
393    }
394}
395
396#[doc(alias = "g_get_locale_variants")]
397#[doc(alias = "get_locale_variants")]
398pub fn locale_variants(locale: &str) -> Vec<crate::GString> {
399    unsafe {
400        FromGlibPtrContainer::from_glib_full(ffi::g_get_locale_variants(locale.to_glib_none().0))
401    }
402}
403
404#[doc(alias = "g_get_monotonic_time")]
405#[doc(alias = "get_monotonic_time")]
406pub fn monotonic_time() -> i64 {
407    unsafe { ffi::g_get_monotonic_time() }
408}
409
410#[doc(alias = "g_get_num_processors")]
411#[doc(alias = "get_num_processors")]
412pub fn num_processors() -> u32 {
413    unsafe { ffi::g_get_num_processors() }
414}
415
416#[cfg(feature = "v2_64")]
417#[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))]
418#[doc(alias = "g_get_os_info")]
419#[doc(alias = "get_os_info")]
420pub fn os_info(key_name: &str) -> Option<crate::GString> {
421    unsafe { from_glib_full(ffi::g_get_os_info(key_name.to_glib_none().0)) }
422}
423
424#[doc(alias = "g_get_real_name")]
425#[doc(alias = "get_real_name")]
426pub fn real_name() -> std::ffi::OsString {
427    unsafe { from_glib_none(ffi::g_get_real_name()) }
428}
429
430#[doc(alias = "g_get_real_time")]
431#[doc(alias = "get_real_time")]
432pub fn real_time() -> i64 {
433    unsafe { ffi::g_get_real_time() }
434}
435
436#[doc(alias = "g_get_system_config_dirs")]
437#[doc(alias = "get_system_config_dirs")]
438pub fn system_config_dirs() -> Vec<std::path::PathBuf> {
439    unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_get_system_config_dirs()) }
440}
441
442#[doc(alias = "g_get_system_data_dirs")]
443#[doc(alias = "get_system_data_dirs")]
444pub fn system_data_dirs() -> Vec<std::path::PathBuf> {
445    unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_get_system_data_dirs()) }
446}
447
448#[doc(alias = "g_get_tmp_dir")]
449#[doc(alias = "get_tmp_dir")]
450pub fn tmp_dir() -> std::path::PathBuf {
451    unsafe { from_glib_none(ffi::g_get_tmp_dir()) }
452}
453
454#[doc(alias = "g_get_user_cache_dir")]
455#[doc(alias = "get_user_cache_dir")]
456pub fn user_cache_dir() -> std::path::PathBuf {
457    unsafe { from_glib_none(ffi::g_get_user_cache_dir()) }
458}
459
460#[doc(alias = "g_get_user_config_dir")]
461#[doc(alias = "get_user_config_dir")]
462pub fn user_config_dir() -> std::path::PathBuf {
463    unsafe { from_glib_none(ffi::g_get_user_config_dir()) }
464}
465
466#[doc(alias = "g_get_user_data_dir")]
467#[doc(alias = "get_user_data_dir")]
468pub fn user_data_dir() -> std::path::PathBuf {
469    unsafe { from_glib_none(ffi::g_get_user_data_dir()) }
470}
471
472#[doc(alias = "g_get_user_name")]
473#[doc(alias = "get_user_name")]
474pub fn user_name() -> std::ffi::OsString {
475    unsafe { from_glib_none(ffi::g_get_user_name()) }
476}
477
478#[doc(alias = "g_get_user_runtime_dir")]
479#[doc(alias = "get_user_runtime_dir")]
480pub fn user_runtime_dir() -> std::path::PathBuf {
481    unsafe { from_glib_none(ffi::g_get_user_runtime_dir()) }
482}
483
484#[doc(alias = "g_get_user_special_dir")]
485#[doc(alias = "get_user_special_dir")]
486pub fn user_special_dir(directory: UserDirectory) -> Option<std::path::PathBuf> {
487    unsafe { from_glib_none(ffi::g_get_user_special_dir(directory.into_glib())) }
488}
489
490#[cfg(feature = "v2_72")]
491#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
492#[doc(alias = "g_get_user_state_dir")]
493#[doc(alias = "get_user_state_dir")]
494pub fn user_state_dir() -> std::path::PathBuf {
495    unsafe { from_glib_none(ffi::g_get_user_state_dir()) }
496}
497
498#[doc(alias = "g_getenv")]
499pub fn getenv(variable: impl AsRef<std::ffi::OsStr>) -> Option<std::ffi::OsString> {
500    unsafe { from_glib_none(ffi::g_getenv(variable.as_ref().to_glib_none().0)) }
501}
502
503#[doc(alias = "g_hostname_is_ascii_encoded")]
504pub fn hostname_is_ascii_encoded(hostname: &str) -> bool {
505    unsafe { from_glib(ffi::g_hostname_is_ascii_encoded(hostname.to_glib_none().0)) }
506}
507
508#[doc(alias = "g_hostname_is_ip_address")]
509pub fn hostname_is_ip_address(hostname: &str) -> bool {
510    unsafe { from_glib(ffi::g_hostname_is_ip_address(hostname.to_glib_none().0)) }
511}
512
513#[doc(alias = "g_hostname_is_non_ascii")]
514pub fn hostname_is_non_ascii(hostname: &str) -> bool {
515    unsafe { from_glib(ffi::g_hostname_is_non_ascii(hostname.to_glib_none().0)) }
516}
517
518#[doc(alias = "g_hostname_to_ascii")]
519pub fn hostname_to_ascii(hostname: &str) -> Option<crate::GString> {
520    unsafe { from_glib_full(ffi::g_hostname_to_ascii(hostname.to_glib_none().0)) }
521}
522
523#[doc(alias = "g_hostname_to_unicode")]
524pub fn hostname_to_unicode(hostname: &str) -> Option<crate::GString> {
525    unsafe { from_glib_full(ffi::g_hostname_to_unicode(hostname.to_glib_none().0)) }
526}
527
528#[doc(alias = "g_listenv")]
529pub fn listenv() -> Vec<std::ffi::OsString> {
530    unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_listenv()) }
531}
532
533#[doc(alias = "g_main_current_source")]
534pub fn main_current_source() -> Option<Source> {
535    unsafe { from_glib_none(ffi::g_main_current_source()) }
536}
537
538#[doc(alias = "g_main_depth")]
539pub fn main_depth() -> i32 {
540    unsafe { ffi::g_main_depth() }
541}
542
543#[doc(alias = "g_markup_escape_text")]
544pub fn markup_escape_text(text: &str) -> crate::GString {
545    let length = text.len() as _;
546    unsafe { from_glib_full(ffi::g_markup_escape_text(text.to_glib_none().0, length)) }
547}
548
549#[doc(alias = "g_mkdir_with_parents")]
550pub fn mkdir_with_parents(pathname: impl AsRef<std::path::Path>, mode: i32) -> i32 {
551    unsafe { ffi::g_mkdir_with_parents(pathname.as_ref().to_glib_none().0, mode) }
552}
553
554#[doc(alias = "g_on_error_query")]
555pub fn on_error_query(prg_name: &str) {
556    unsafe {
557        ffi::g_on_error_query(prg_name.to_glib_none().0);
558    }
559}
560
561#[doc(alias = "g_on_error_stack_trace")]
562pub fn on_error_stack_trace(prg_name: Option<&str>) {
563    unsafe {
564        ffi::g_on_error_stack_trace(prg_name.to_glib_none().0);
565    }
566}
567
568#[doc(alias = "g_path_get_basename")]
569#[allow(dead_code)]
570pub(crate) fn path_get_basename(file_name: impl AsRef<std::path::Path>) -> std::path::PathBuf {
571    unsafe {
572        from_glib_full(ffi::g_path_get_basename(
573            file_name.as_ref().to_glib_none().0,
574        ))
575    }
576}
577
578#[doc(alias = "g_path_get_dirname")]
579#[allow(dead_code)]
580pub(crate) fn path_get_dirname(file_name: impl AsRef<std::path::Path>) -> std::path::PathBuf {
581    unsafe { from_glib_full(ffi::g_path_get_dirname(file_name.as_ref().to_glib_none().0)) }
582}
583
584//#[doc(alias = "g_poll")]
585//pub fn poll(fds: /*Ignored*/&mut PollFD, nfds: u32, timeout: i32) -> i32 {
586//    unsafe { TODO: call ffi:g_poll() }
587//}
588
589#[doc(alias = "g_random_double")]
590pub fn random_double() -> f64 {
591    unsafe { ffi::g_random_double() }
592}
593
594#[doc(alias = "g_random_double_range")]
595pub fn random_double_range(begin: f64, end: f64) -> f64 {
596    unsafe { ffi::g_random_double_range(begin, end) }
597}
598
599#[doc(alias = "g_random_int")]
600pub fn random_int() -> u32 {
601    unsafe { ffi::g_random_int() }
602}
603
604#[doc(alias = "g_random_int_range")]
605pub fn random_int_range(begin: i32, end: i32) -> i32 {
606    unsafe { ffi::g_random_int_range(begin, end) }
607}
608
609#[doc(alias = "g_random_set_seed")]
610pub fn random_set_seed(seed: u32) {
611    unsafe {
612        ffi::g_random_set_seed(seed);
613    }
614}
615
616#[doc(alias = "g_reload_user_special_dirs_cache")]
617pub fn reload_user_special_dirs_cache() {
618    unsafe {
619        ffi::g_reload_user_special_dirs_cache();
620    }
621}
622
623#[doc(alias = "g_set_application_name")]
624pub fn set_application_name(application_name: &str) {
625    unsafe {
626        ffi::g_set_application_name(application_name.to_glib_none().0);
627    }
628}
629
630#[doc(alias = "g_setenv")]
631pub fn setenv(
632    variable: impl AsRef<std::ffi::OsStr>,
633    value: impl AsRef<std::ffi::OsStr>,
634    overwrite: bool,
635) -> Result<(), crate::error::BoolError> {
636    unsafe {
637        crate::result_from_gboolean!(
638            ffi::g_setenv(
639                variable.as_ref().to_glib_none().0,
640                value.as_ref().to_glib_none().0,
641                overwrite.into_glib()
642            ),
643            "Failed to set environment variable"
644        )
645    }
646}
647
648#[doc(alias = "g_shell_parse_argv")]
649pub fn shell_parse_argv(
650    command_line: impl AsRef<std::ffi::OsStr>,
651) -> Result<Vec<std::ffi::OsString>, crate::Error> {
652    unsafe {
653        let mut argcp = std::mem::MaybeUninit::uninit();
654        let mut argvp = std::ptr::null_mut();
655        let mut error = std::ptr::null_mut();
656        let is_ok = ffi::g_shell_parse_argv(
657            command_line.as_ref().to_glib_none().0,
658            argcp.as_mut_ptr(),
659            &mut argvp,
660            &mut error,
661        );
662        debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
663        if error.is_null() {
664            Ok(FromGlibContainer::from_glib_full_num(
665                argvp,
666                argcp.assume_init() as _,
667            ))
668        } else {
669            Err(from_glib_full(error))
670        }
671    }
672}
673
674#[doc(alias = "g_shell_quote")]
675pub fn shell_quote(unquoted_string: impl AsRef<std::ffi::OsStr>) -> std::ffi::OsString {
676    unsafe {
677        from_glib_full(ffi::g_shell_quote(
678            unquoted_string.as_ref().to_glib_none().0,
679        ))
680    }
681}
682
683#[doc(alias = "g_shell_unquote")]
684pub fn shell_unquote(
685    quoted_string: impl AsRef<std::ffi::OsStr>,
686) -> Result<std::ffi::OsString, crate::Error> {
687    unsafe {
688        let mut error = std::ptr::null_mut();
689        let ret = ffi::g_shell_unquote(quoted_string.as_ref().to_glib_none().0, &mut error);
690        if error.is_null() {
691            Ok(from_glib_full(ret))
692        } else {
693            Err(from_glib_full(error))
694        }
695    }
696}
697
698//#[cfg(feature = "v2_82")]
699//#[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))]
700//#[doc(alias = "g_sort_array")]
701//pub fn sort_array(array: /*Unimplemented*/&[&Basic: Pointer], element_size: usize, compare_func: /*Unimplemented*/FnMut(/*Unimplemented*/Option<Basic: Pointer>, /*Unimplemented*/Option<Basic: Pointer>) -> i32, user_data: /*Unimplemented*/Option<Basic: Pointer>) {
702//    unsafe { TODO: call ffi:g_sort_array() }
703//}
704
705#[doc(alias = "g_spaced_primes_closest")]
706pub fn spaced_primes_closest(num: u32) -> u32 {
707    unsafe { ffi::g_spaced_primes_closest(num) }
708}
709
710#[doc(alias = "g_spawn_async")]
711pub fn spawn_async(
712    working_directory: Option<impl AsRef<std::path::Path>>,
713    argv: &[&std::path::Path],
714    envp: &[&std::path::Path],
715    flags: SpawnFlags,
716    child_setup: Option<Box_<dyn FnOnce() + 'static>>,
717) -> Result<Pid, crate::Error> {
718    let child_setup_data: Box_<Option<Box_<dyn FnOnce() + 'static>>> = Box_::new(child_setup);
719    unsafe extern "C" fn child_setup_func(data: ffi::gpointer) {
720        let callback = Box_::from_raw(data as *mut Option<Box_<dyn FnOnce() + 'static>>);
721        let callback = (*callback).expect("cannot get closure...");
722        callback()
723    }
724    let child_setup = if child_setup_data.is_some() {
725        Some(child_setup_func as _)
726    } else {
727        None
728    };
729    let super_callback0: Box_<Option<Box_<dyn FnOnce() + 'static>>> = child_setup_data;
730    unsafe {
731        let mut child_pid = std::mem::MaybeUninit::uninit();
732        let mut error = std::ptr::null_mut();
733        let is_ok = ffi::g_spawn_async(
734            working_directory
735                .as_ref()
736                .map(|p| p.as_ref())
737                .to_glib_none()
738                .0,
739            argv.to_glib_none().0,
740            envp.to_glib_none().0,
741            flags.into_glib(),
742            child_setup,
743            Box_::into_raw(super_callback0) as *mut _,
744            child_pid.as_mut_ptr(),
745            &mut error,
746        );
747        debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
748        if error.is_null() {
749            Ok(from_glib(child_pid.assume_init()))
750        } else {
751            Err(from_glib_full(error))
752        }
753    }
754}
755
756//#[cfg(feature = "v2_68")]
757//#[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))]
758//#[doc(alias = "g_spawn_async_with_pipes_and_fds")]
759//pub fn spawn_async_with_pipes_and_fds(working_directory: Option<impl AsRef<std::path::Path>>, argv: &[&std::path::Path], envp: &[&std::path::Path], flags: SpawnFlags, child_setup: Option<Box_<dyn FnOnce() + 'static>>, stdin_fd: i32, stdout_fd: i32, stderr_fd: i32, source_fds: &[i32], target_fds: &[i32], n_fds: usize) -> Result<(Pid, i32, i32, i32), crate::Error> {
760//    unsafe { TODO: call ffi:g_spawn_async_with_pipes_and_fds() }
761//}
762
763#[cfg_attr(feature = "v2_70", deprecated = "Since 2.70")]
764#[allow(deprecated)]
765#[doc(alias = "g_spawn_check_exit_status")]
766pub fn spawn_check_exit_status(wait_status: i32) -> Result<(), crate::Error> {
767    unsafe {
768        let mut error = std::ptr::null_mut();
769        let is_ok = ffi::g_spawn_check_exit_status(wait_status, &mut error);
770        debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
771        if error.is_null() {
772            Ok(())
773        } else {
774            Err(from_glib_full(error))
775        }
776    }
777}
778
779#[cfg(feature = "v2_70")]
780#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
781#[doc(alias = "g_spawn_check_wait_status")]
782pub fn spawn_check_wait_status(wait_status: i32) -> Result<(), crate::Error> {
783    unsafe {
784        let mut error = std::ptr::null_mut();
785        let is_ok = ffi::g_spawn_check_wait_status(wait_status, &mut error);
786        debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
787        if error.is_null() {
788            Ok(())
789        } else {
790            Err(from_glib_full(error))
791        }
792    }
793}
794
795#[cfg(unix)]
796#[cfg_attr(docsrs, doc(cfg(unix)))]
797#[doc(alias = "g_spawn_command_line_async")]
798pub fn spawn_command_line_async(
799    command_line: impl AsRef<std::ffi::OsStr>,
800) -> Result<(), crate::Error> {
801    unsafe {
802        let mut error = std::ptr::null_mut();
803        let is_ok =
804            ffi::g_spawn_command_line_async(command_line.as_ref().to_glib_none().0, &mut error);
805        debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
806        if error.is_null() {
807            Ok(())
808        } else {
809            Err(from_glib_full(error))
810        }
811    }
812}
813
814//#[doc(alias = "g_spawn_command_line_sync")]
815//pub fn spawn_command_line_sync(command_line: impl AsRef<std::path::Path>, standard_output: Vec<u8>, standard_error: Vec<u8>) -> Result<i32, crate::Error> {
816//    unsafe { TODO: call ffi:g_spawn_command_line_sync() }
817//}
818
819//#[doc(alias = "g_spawn_sync")]
820//pub fn spawn_sync(working_directory: Option<impl AsRef<std::path::Path>>, argv: &[&std::path::Path], envp: &[&std::path::Path], flags: SpawnFlags, child_setup: Option<&mut dyn (FnMut())>, standard_output: Vec<u8>, standard_error: Vec<u8>) -> Result<i32, crate::Error> {
821//    unsafe { TODO: call ffi:g_spawn_sync() }
822//}
823
824//#[doc(alias = "g_stat")]
825//pub fn stat(filename: impl AsRef<std::path::Path>, buf: /*Ignored*/&mut StatBuf) -> i32 {
826//    unsafe { TODO: call ffi:g_stat() }
827//}
828
829//#[cfg(unix)]
830//#[cfg_attr(docsrs, doc(cfg(unix)))]
831//#[cfg(feature = "v2_64")]
832//#[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))]
833//#[doc(alias = "g_unix_get_passwd_entry")]
834//pub fn unix_get_passwd_entry(user_name: &str) -> Result</*Unimplemented*/Option<Basic: Pointer>, crate::Error> {
835//    unsafe { TODO: call ffi:g_unix_get_passwd_entry() }
836//}
837
838#[doc(alias = "g_unlink")]
839pub fn unlink(filename: impl AsRef<std::path::Path>) -> i32 {
840    unsafe { ffi::g_unlink(filename.as_ref().to_glib_none().0) }
841}
842
843#[doc(alias = "g_unsetenv")]
844pub fn unsetenv(variable: impl AsRef<std::ffi::OsStr>) {
845    unsafe {
846        ffi::g_unsetenv(variable.as_ref().to_glib_none().0);
847    }
848}
849
850#[doc(alias = "g_usleep")]
851pub fn usleep(microseconds: libc::c_ulong) {
852    unsafe {
853        ffi::g_usleep(microseconds);
854    }
855}
856
857#[doc(alias = "g_uuid_string_is_valid")]
858pub fn uuid_string_is_valid(str: &str) -> bool {
859    unsafe { from_glib(ffi::g_uuid_string_is_valid(str.to_glib_none().0)) }
860}
861
862#[doc(alias = "g_uuid_string_random")]
863pub fn uuid_string_random() -> crate::GString {
864    unsafe { from_glib_full(ffi::g_uuid_string_random()) }
865}