gio/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
5use crate::{
6    ffi, AsyncResult, BusType, Cancellable, DBusConnection, File, IOErrorEnum, IOStream, Icon,
7    InputStream, Resource, ResourceLookupFlags, SettingsBackend,
8};
9use glib::{prelude::*, translate::*};
10use std::{boxed::Box as Box_, pin::Pin};
11
12/// Asynchronously connects to the message bus specified by @bus_type.
13///
14/// When the operation is finished, @callback will be invoked. You can
15/// then call g_bus_get_finish() to get the result of the operation.
16///
17/// This is an asynchronous failable function. See g_bus_get_sync() for
18/// the synchronous version.
19/// ## `bus_type`
20/// a #GBusType
21/// ## `cancellable`
22/// a #GCancellable or [`None`]
23/// ## `callback`
24/// a #GAsyncReadyCallback to call when the request is satisfied
25#[doc(alias = "g_bus_get")]
26pub fn bus_get<P: FnOnce(Result<DBusConnection, glib::Error>) + 'static>(
27    bus_type: BusType,
28    cancellable: Option<&impl IsA<Cancellable>>,
29    callback: P,
30) {
31    let main_context = glib::MainContext::ref_thread_default();
32    let is_main_context_owner = main_context.is_owner();
33    let has_acquired_main_context = (!is_main_context_owner)
34        .then(|| main_context.acquire().ok())
35        .flatten();
36    assert!(
37        is_main_context_owner || has_acquired_main_context.is_some(),
38        "Async operations only allowed if the thread is owning the MainContext"
39    );
40
41    let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
42        Box_::new(glib::thread_guard::ThreadGuard::new(callback));
43    unsafe extern "C" fn bus_get_trampoline<
44        P: FnOnce(Result<DBusConnection, glib::Error>) + 'static,
45    >(
46        _source_object: *mut glib::gobject_ffi::GObject,
47        res: *mut crate::ffi::GAsyncResult,
48        user_data: glib::ffi::gpointer,
49    ) {
50        let mut error = std::ptr::null_mut();
51        let ret = ffi::g_bus_get_finish(res, &mut error);
52        let result = if error.is_null() {
53            Ok(from_glib_full(ret))
54        } else {
55            Err(from_glib_full(error))
56        };
57        let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
58            Box_::from_raw(user_data as *mut _);
59        let callback: P = callback.into_inner();
60        callback(result);
61    }
62    let callback = bus_get_trampoline::<P>;
63    unsafe {
64        ffi::g_bus_get(
65            bus_type.into_glib(),
66            cancellable.map(|p| p.as_ref()).to_glib_none().0,
67            Some(callback),
68            Box_::into_raw(user_data) as *mut _,
69        );
70    }
71}
72
73pub fn bus_get_future(
74    bus_type: BusType,
75) -> Pin<Box_<dyn std::future::Future<Output = Result<DBusConnection, glib::Error>> + 'static>> {
76    Box_::pin(crate::GioFuture::new(
77        &(),
78        move |_obj, cancellable, send| {
79            bus_get(bus_type, Some(cancellable), move |res| {
80                send.resolve(res);
81            });
82        },
83    ))
84}
85
86/// Synchronously connects to the message bus specified by @bus_type.
87/// Note that the returned object may shared with other callers,
88/// e.g. if two separate parts of a process calls this function with
89/// the same @bus_type, they will share the same object.
90///
91/// This is a synchronous failable function. See g_bus_get() and
92/// g_bus_get_finish() for the asynchronous version.
93///
94/// The returned object is a singleton, that is, shared with other
95/// callers of g_bus_get() and g_bus_get_sync() for @bus_type. In the
96/// event that you need a private message bus connection, use
97/// g_dbus_address_get_for_bus_sync() and
98/// g_dbus_connection_new_for_address() with
99/// G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT and
100/// G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION flags.
101///
102/// Note that the returned #GDBusConnection object will (usually) have
103/// the #GDBusConnection:exit-on-close property set to [`true`].
104/// ## `bus_type`
105/// a #GBusType
106/// ## `cancellable`
107/// a #GCancellable or [`None`]
108///
109/// # Returns
110///
111/// a #GDBusConnection or [`None`] if @error is set.
112///     Free with g_object_unref().
113#[doc(alias = "g_bus_get_sync")]
114pub fn bus_get_sync(
115    bus_type: BusType,
116    cancellable: Option<&impl IsA<Cancellable>>,
117) -> Result<DBusConnection, glib::Error> {
118    unsafe {
119        let mut error = std::ptr::null_mut();
120        let ret = ffi::g_bus_get_sync(
121            bus_type.into_glib(),
122            cancellable.map(|p| p.as_ref()).to_glib_none().0,
123            &mut error,
124        );
125        if error.is_null() {
126            Ok(from_glib_full(ret))
127        } else {
128            Err(from_glib_full(error))
129        }
130    }
131}
132
133//#[doc(alias = "g_bus_own_name")]
134//pub fn bus_own_name(bus_type: BusType, name: &str, flags: BusNameOwnerFlags, bus_acquired_handler: Option<Box_<dyn Fn(&DBusConnection, &str) + 'static>>, name_acquired_handler: Option<Box_<dyn Fn(&DBusConnection, &str) + 'static>>, name_lost_handler: Option<Box_<dyn Fn(&DBusConnection, &str) + 'static>>) -> u32 {
135//    unsafe { TODO: call ffi:g_bus_own_name() }
136//}
137
138//#[doc(alias = "g_bus_own_name_on_connection")]
139//pub fn bus_own_name_on_connection(connection: &DBusConnection, name: &str, flags: BusNameOwnerFlags, name_acquired_handler: Option<Box_<dyn Fn(&DBusConnection, &str) + 'static>>, name_lost_handler: Option<Box_<dyn Fn(&DBusConnection, &str) + 'static>>) -> u32 {
140//    unsafe { TODO: call ffi:g_bus_own_name_on_connection() }
141//}
142
143//#[doc(alias = "g_bus_watch_name")]
144//pub fn bus_watch_name(bus_type: BusType, name: &str, flags: BusNameWatcherFlags, name_appeared_handler: Option<Box_<dyn Fn(&DBusConnection, &str, &str) + 'static>>, name_vanished_handler: Option<Box_<dyn Fn(&DBusConnection, &str) + 'static>>) -> u32 {
145//    unsafe { TODO: call ffi:g_bus_watch_name() }
146//}
147
148//#[doc(alias = "g_bus_watch_name_on_connection")]
149//pub fn bus_watch_name_on_connection(connection: &DBusConnection, name: &str, flags: BusNameWatcherFlags, name_appeared_handler: Option<Box_<dyn Fn(&DBusConnection, &str, &str) + 'static>>, name_vanished_handler: Option<Box_<dyn Fn(&DBusConnection, &str) + 'static>>) -> u32 {
150//    unsafe { TODO: call ffi:g_bus_watch_name_on_connection() }
151//}
152
153/// Checks if a content type can be executable. Note that for instance
154/// things like text files can be executables (i.e. scripts and batch files).
155/// ## `type_`
156/// a content type string
157///
158/// # Returns
159///
160/// [`true`] if the file type corresponds to a type that
161///     can be executable, [`false`] otherwise.
162#[doc(alias = "g_content_type_can_be_executable")]
163pub fn content_type_can_be_executable(type_: &str) -> bool {
164    unsafe {
165        from_glib(ffi::g_content_type_can_be_executable(
166            type_.to_glib_none().0,
167        ))
168    }
169}
170
171/// Compares two content types for equality.
172/// ## `type1`
173/// a content type string
174/// ## `type2`
175/// a content type string
176///
177/// # Returns
178///
179/// [`true`] if the two strings are identical or equivalent,
180///     [`false`] otherwise.
181#[doc(alias = "g_content_type_equals")]
182pub fn content_type_equals(type1: &str, type2: &str) -> bool {
183    unsafe {
184        from_glib(ffi::g_content_type_equals(
185            type1.to_glib_none().0,
186            type2.to_glib_none().0,
187        ))
188    }
189}
190
191/// Tries to find a content type based on the mime type name.
192/// ## `mime_type`
193/// a mime type string
194///
195/// # Returns
196///
197/// Newly allocated string with content type or
198///     [`None`]. Free with g_free()
199#[doc(alias = "g_content_type_from_mime_type")]
200pub fn content_type_from_mime_type(mime_type: &str) -> Option<glib::GString> {
201    unsafe {
202        from_glib_full(ffi::g_content_type_from_mime_type(
203            mime_type.to_glib_none().0,
204        ))
205    }
206}
207
208/// Gets the human readable description of the content type.
209/// ## `type_`
210/// a content type string
211///
212/// # Returns
213///
214/// a short description of the content type @type_. Free the
215///     returned string with g_free()
216#[doc(alias = "g_content_type_get_description")]
217pub fn content_type_get_description(type_: &str) -> glib::GString {
218    unsafe { from_glib_full(ffi::g_content_type_get_description(type_.to_glib_none().0)) }
219}
220
221/// Gets the generic icon name for a content type.
222///
223/// See the
224/// [shared-mime-info](http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec)
225/// specification for more on the generic icon name.
226/// ## `type_`
227/// a content type string
228///
229/// # Returns
230///
231/// the registered generic icon name for the given @type_,
232///     or [`None`] if unknown. Free with g_free()
233#[doc(alias = "g_content_type_get_generic_icon_name")]
234pub fn content_type_get_generic_icon_name(type_: &str) -> Option<glib::GString> {
235    unsafe {
236        from_glib_full(ffi::g_content_type_get_generic_icon_name(
237            type_.to_glib_none().0,
238        ))
239    }
240}
241
242/// Gets the icon for a content type.
243/// ## `type_`
244/// a content type string
245///
246/// # Returns
247///
248/// #GIcon corresponding to the content type. Free the returned
249///     object with g_object_unref()
250#[doc(alias = "g_content_type_get_icon")]
251pub fn content_type_get_icon(type_: &str) -> Icon {
252    unsafe { from_glib_full(ffi::g_content_type_get_icon(type_.to_glib_none().0)) }
253}
254
255/// Get the list of directories which MIME data is loaded from. See
256/// g_content_type_set_mime_dirs() for details.
257///
258/// # Returns
259///
260/// [`None`]-terminated list of
261///    directories to load MIME data from, including any `mime/` subdirectory,
262///    and with the first directory to try listed first
263#[cfg(feature = "v2_60")]
264#[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
265#[doc(alias = "g_content_type_get_mime_dirs")]
266pub fn content_type_get_mime_dirs() -> Vec<glib::GString> {
267    unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_content_type_get_mime_dirs()) }
268}
269
270/// Gets the mime type for the content type, if one is registered.
271/// ## `type_`
272/// a content type string
273///
274/// # Returns
275///
276/// the registered mime type for the
277///     given @type_, or [`None`] if unknown; free with g_free().
278#[doc(alias = "g_content_type_get_mime_type")]
279pub fn content_type_get_mime_type(type_: &str) -> Option<glib::GString> {
280    unsafe { from_glib_full(ffi::g_content_type_get_mime_type(type_.to_glib_none().0)) }
281}
282
283/// Gets the symbolic icon for a content type.
284/// ## `type_`
285/// a content type string
286///
287/// # Returns
288///
289/// symbolic #GIcon corresponding to the content type.
290///     Free the returned object with g_object_unref()
291#[doc(alias = "g_content_type_get_symbolic_icon")]
292pub fn content_type_get_symbolic_icon(type_: &str) -> Icon {
293    unsafe {
294        from_glib_full(ffi::g_content_type_get_symbolic_icon(
295            type_.to_glib_none().0,
296        ))
297    }
298}
299
300/// Guesses the content type based on example data. If the function is
301/// uncertain, @result_uncertain will be set to [`true`]. Either @filename
302/// or @data may be [`None`], in which case the guess will be based solely
303/// on the other argument.
304/// ## `filename`
305/// a path, or [`None`]
306/// ## `data`
307/// a stream of data, or [`None`]
308///
309/// # Returns
310///
311/// a string indicating a guessed content type for the
312///     given data. Free with g_free()
313///
314/// ## `result_uncertain`
315/// return location for the certainty
316///     of the result, or [`None`]
317#[doc(alias = "g_content_type_guess")]
318pub fn content_type_guess(
319    filename: Option<impl AsRef<std::path::Path>>,
320    data: &[u8],
321) -> (glib::GString, bool) {
322    let data_size = data.len() as _;
323    unsafe {
324        let mut result_uncertain = std::mem::MaybeUninit::uninit();
325        let ret = from_glib_full(ffi::g_content_type_guess(
326            filename.as_ref().map(|p| p.as_ref()).to_glib_none().0,
327            data.to_glib_none().0,
328            data_size,
329            result_uncertain.as_mut_ptr(),
330        ));
331        (ret, from_glib(result_uncertain.assume_init()))
332    }
333}
334
335/// Tries to guess the type of the tree with root @root, by
336/// looking at the files it contains. The result is an array
337/// of content types, with the best guess coming first.
338///
339/// The types returned all have the form x-content/foo, e.g.
340/// x-content/audio-cdda (for audio CDs) or x-content/image-dcf
341/// (for a camera memory card). See the
342/// [shared-mime-info](http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec)
343/// specification for more on x-content types.
344///
345/// This function is useful in the implementation of
346/// g_mount_guess_content_type().
347/// ## `root`
348/// the root of the tree to guess a type for
349///
350/// # Returns
351///
352/// an [`None`]-terminated
353///     array of zero or more content types. Free with g_strfreev()
354#[doc(alias = "g_content_type_guess_for_tree")]
355pub fn content_type_guess_for_tree(root: &impl IsA<File>) -> Vec<glib::GString> {
356    unsafe {
357        FromGlibPtrContainer::from_glib_full(ffi::g_content_type_guess_for_tree(
358            root.as_ref().to_glib_none().0,
359        ))
360    }
361}
362
363/// Determines if @type_ is a subset of @supertype.
364/// ## `type_`
365/// a content type string
366/// ## `supertype`
367/// a content type string
368///
369/// # Returns
370///
371/// [`true`] if @type_ is a kind of @supertype,
372///     [`false`] otherwise.
373#[doc(alias = "g_content_type_is_a")]
374pub fn content_type_is_a(type_: &str, supertype: &str) -> bool {
375    unsafe {
376        from_glib(ffi::g_content_type_is_a(
377            type_.to_glib_none().0,
378            supertype.to_glib_none().0,
379        ))
380    }
381}
382
383/// Determines if @type_ is a subset of @mime_type.
384/// Convenience wrapper around g_content_type_is_a().
385/// ## `type_`
386/// a content type string
387/// ## `mime_type`
388/// a mime type string
389///
390/// # Returns
391///
392/// [`true`] if @type_ is a kind of @mime_type,
393///     [`false`] otherwise.
394#[doc(alias = "g_content_type_is_mime_type")]
395pub fn content_type_is_mime_type(type_: &str, mime_type: &str) -> bool {
396    unsafe {
397        from_glib(ffi::g_content_type_is_mime_type(
398            type_.to_glib_none().0,
399            mime_type.to_glib_none().0,
400        ))
401    }
402}
403
404/// Checks if the content type is the generic "unknown" type.
405/// On UNIX this is the "application/octet-stream" mimetype,
406/// while on win32 it is "*" and on OSX it is a dynamic type
407/// or octet-stream.
408/// ## `type_`
409/// a content type string
410///
411/// # Returns
412///
413/// [`true`] if the type is the unknown type.
414#[doc(alias = "g_content_type_is_unknown")]
415pub fn content_type_is_unknown(type_: &str) -> bool {
416    unsafe { from_glib(ffi::g_content_type_is_unknown(type_.to_glib_none().0)) }
417}
418
419/// Set the list of directories used by GIO to load the MIME database.
420/// If @dirs is [`None`], the directories used are the default:
421///
422///  - the `mime` subdirectory of the directory in `$XDG_DATA_HOME`
423///  - the `mime` subdirectory of every directory in `$XDG_DATA_DIRS`
424///
425/// This function is intended to be used when writing tests that depend on
426/// information stored in the MIME database, in order to control the data.
427///
428/// Typically, in case your tests use `G_TEST_OPTION_ISOLATE_DIRS`, but they
429/// depend on the system’s MIME database, you should call this function
430/// with @dirs set to [`None`] before calling g_test_init(), for instance:
431///
432///
433///
434/// **⚠️ The following code is in C ⚠️**
435///
436/// ```C
437///   // Load MIME data from the system
438///   g_content_type_set_mime_dirs (NULL);
439///   // Isolate the environment
440///   g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
441///
442///   …
443///
444///   return g_test_run ();
445/// ```
446/// ## `dirs`
447/// [`None`]-terminated list of
448///    directories to load MIME data from, including any `mime/` subdirectory,
449///    and with the first directory to try listed first
450#[cfg(feature = "v2_60")]
451#[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
452#[doc(alias = "g_content_type_set_mime_dirs")]
453pub fn content_type_set_mime_dirs(dirs: &[&str]) {
454    unsafe {
455        ffi::g_content_type_set_mime_dirs(dirs.to_glib_none().0);
456    }
457}
458
459/// Gets a list of strings containing all the registered content types
460/// known to the system. The list and its data should be freed using
461/// `g_list_free_full (list, g_free)`.
462///
463/// # Returns
464///
465/// list of the registered
466///     content types
467#[doc(alias = "g_content_types_get_registered")]
468pub fn content_types_get_registered() -> Vec<glib::GString> {
469    unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_content_types_get_registered()) }
470}
471
472/// Escape @string so it can appear in a D-Bus address as the value
473/// part of a key-value pair.
474///
475/// For instance, if @string is `/run/bus-for-:0`,
476/// this function would return `/run/bus-for-`3A0``,
477/// which could be used in a D-Bus address like
478/// `unix:nonce-tcp:host=127.0.0.1,port=42,noncefile=/run/bus-for-`3A0``.
479/// ## `string`
480/// an unescaped string to be included in a D-Bus address
481///     as the value in a key-value pair
482///
483/// # Returns
484///
485/// a copy of @string with all
486///     non-optionally-escaped bytes escaped
487#[doc(alias = "g_dbus_address_escape_value")]
488pub fn dbus_address_escape_value(string: &str) -> glib::GString {
489    unsafe { from_glib_full(ffi::g_dbus_address_escape_value(string.to_glib_none().0)) }
490}
491
492/// Synchronously looks up the D-Bus address for the well-known message
493/// bus instance specified by @bus_type. This may involve using various
494/// platform specific mechanisms.
495///
496/// The returned address will be in the
497/// [D-Bus address format](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses).
498/// ## `bus_type`
499/// a #GBusType
500/// ## `cancellable`
501/// a #GCancellable or [`None`]
502///
503/// # Returns
504///
505/// a valid D-Bus address string for @bus_type or
506///     [`None`] if @error is set
507#[doc(alias = "g_dbus_address_get_for_bus_sync")]
508pub fn dbus_address_get_for_bus_sync(
509    bus_type: BusType,
510    cancellable: Option<&impl IsA<Cancellable>>,
511) -> Result<glib::GString, glib::Error> {
512    unsafe {
513        let mut error = std::ptr::null_mut();
514        let ret = ffi::g_dbus_address_get_for_bus_sync(
515            bus_type.into_glib(),
516            cancellable.map(|p| p.as_ref()).to_glib_none().0,
517            &mut error,
518        );
519        if error.is_null() {
520            Ok(from_glib_full(ret))
521        } else {
522            Err(from_glib_full(error))
523        }
524    }
525}
526
527/// Asynchronously connects to an endpoint specified by @address and
528/// sets up the connection so it is in a state to run the client-side
529/// of the D-Bus authentication conversation. @address must be in the
530/// [D-Bus address format](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses).
531///
532/// When the operation is finished, @callback will be invoked. You can
533/// then call g_dbus_address_get_stream_finish() to get the result of
534/// the operation.
535///
536/// This is an asynchronous failable function. See
537/// g_dbus_address_get_stream_sync() for the synchronous version.
538/// ## `address`
539/// A valid D-Bus address.
540/// ## `cancellable`
541/// A #GCancellable or [`None`].
542/// ## `callback`
543/// A #GAsyncReadyCallback to call when the request is satisfied.
544#[doc(alias = "g_dbus_address_get_stream")]
545pub fn dbus_address_get_stream<
546    P: FnOnce(Result<(IOStream, Option<glib::GString>), glib::Error>) + 'static,
547>(
548    address: &str,
549    cancellable: Option<&impl IsA<Cancellable>>,
550    callback: P,
551) {
552    let main_context = glib::MainContext::ref_thread_default();
553    let is_main_context_owner = main_context.is_owner();
554    let has_acquired_main_context = (!is_main_context_owner)
555        .then(|| main_context.acquire().ok())
556        .flatten();
557    assert!(
558        is_main_context_owner || has_acquired_main_context.is_some(),
559        "Async operations only allowed if the thread is owning the MainContext"
560    );
561
562    let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
563        Box_::new(glib::thread_guard::ThreadGuard::new(callback));
564    unsafe extern "C" fn dbus_address_get_stream_trampoline<
565        P: FnOnce(Result<(IOStream, Option<glib::GString>), glib::Error>) + 'static,
566    >(
567        _source_object: *mut glib::gobject_ffi::GObject,
568        res: *mut crate::ffi::GAsyncResult,
569        user_data: glib::ffi::gpointer,
570    ) {
571        let mut error = std::ptr::null_mut();
572        let mut out_guid = std::ptr::null_mut();
573        let ret = ffi::g_dbus_address_get_stream_finish(res, &mut out_guid, &mut error);
574        let result = if error.is_null() {
575            Ok((from_glib_full(ret), from_glib_full(out_guid)))
576        } else {
577            Err(from_glib_full(error))
578        };
579        let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
580            Box_::from_raw(user_data as *mut _);
581        let callback: P = callback.into_inner();
582        callback(result);
583    }
584    let callback = dbus_address_get_stream_trampoline::<P>;
585    unsafe {
586        ffi::g_dbus_address_get_stream(
587            address.to_glib_none().0,
588            cancellable.map(|p| p.as_ref()).to_glib_none().0,
589            Some(callback),
590            Box_::into_raw(user_data) as *mut _,
591        );
592    }
593}
594
595pub fn dbus_address_get_stream_future(
596    address: &str,
597) -> Pin<
598    Box_<
599        dyn std::future::Future<Output = Result<(IOStream, Option<glib::GString>), glib::Error>>
600            + 'static,
601    >,
602> {
603    let address = String::from(address);
604    Box_::pin(crate::GioFuture::new(
605        &(),
606        move |_obj, cancellable, send| {
607            dbus_address_get_stream(&address, Some(cancellable), move |res| {
608                send.resolve(res);
609            });
610        },
611    ))
612}
613
614/// Synchronously connects to an endpoint specified by @address and
615/// sets up the connection so it is in a state to run the client-side
616/// of the D-Bus authentication conversation. @address must be in the
617/// [D-Bus address format](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses).
618///
619/// A server is not required to set a GUID, so @out_guid may be set to [`None`]
620/// even on success.
621///
622/// This is a synchronous failable function. See
623/// g_dbus_address_get_stream() for the asynchronous version.
624/// ## `address`
625/// A valid D-Bus address.
626/// ## `cancellable`
627/// A #GCancellable or [`None`].
628///
629/// # Returns
630///
631/// A #GIOStream or [`None`] if @error is set.
632///
633/// ## `out_guid`
634/// [`None`] or return location to store the GUID extracted from @address, if any.
635#[doc(alias = "g_dbus_address_get_stream_sync")]
636pub fn dbus_address_get_stream_sync(
637    address: &str,
638    cancellable: Option<&impl IsA<Cancellable>>,
639) -> Result<(IOStream, Option<glib::GString>), glib::Error> {
640    unsafe {
641        let mut out_guid = std::ptr::null_mut();
642        let mut error = std::ptr::null_mut();
643        let ret = ffi::g_dbus_address_get_stream_sync(
644            address.to_glib_none().0,
645            &mut out_guid,
646            cancellable.map(|p| p.as_ref()).to_glib_none().0,
647            &mut error,
648        );
649        if error.is_null() {
650            Ok((from_glib_full(ret), from_glib_full(out_guid)))
651        } else {
652            Err(from_glib_full(error))
653        }
654    }
655}
656
657/// This is a language binding friendly version of g_dbus_escape_object_path_bytestring().
658/// ## `s`
659/// the string to escape
660///
661/// # Returns
662///
663/// an escaped version of @s. Free with g_free().
664#[cfg(feature = "v2_68")]
665#[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))]
666#[doc(alias = "g_dbus_escape_object_path")]
667pub fn dbus_escape_object_path(s: &str) -> glib::GString {
668    unsafe { from_glib_full(ffi::g_dbus_escape_object_path(s.to_glib_none().0)) }
669}
670
671//#[cfg(feature = "v2_68")]
672//#[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))]
673//#[doc(alias = "g_dbus_escape_object_path_bytestring")]
674//pub fn dbus_escape_object_path_bytestring(bytes: &[u8]) -> glib::GString {
675//    unsafe { TODO: call ffi:g_dbus_escape_object_path_bytestring() }
676//}
677
678/// Generate a D-Bus GUID that can be used with
679/// e.g. g_dbus_connection_new().
680///
681/// See the
682/// [D-Bus specification](https://dbus.freedesktop.org/doc/dbus-specification.html#uuids)
683/// regarding what strings are valid D-Bus GUIDs. The specification refers to
684/// these as ‘UUIDs’ whereas GLib (for historical reasons) refers to them as
685/// ‘GUIDs’. The terms are interchangeable.
686///
687/// Note that D-Bus GUIDs do not follow
688/// [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122).
689///
690/// # Returns
691///
692/// A valid D-Bus GUID. Free with g_free().
693#[doc(alias = "g_dbus_generate_guid")]
694pub fn dbus_generate_guid() -> glib::GString {
695    unsafe { from_glib_full(ffi::g_dbus_generate_guid()) }
696}
697
698/// Converts a #GValue to a #GVariant of the type indicated by the @type_
699/// parameter.
700///
701/// The conversion is using the following rules:
702///
703/// - `G_TYPE_STRING`: 's', 'o', 'g' or 'ay'
704/// - `G_TYPE_STRV`: 'as', 'ao' or 'aay'
705/// - `G_TYPE_BOOLEAN`: 'b'
706/// - `G_TYPE_UCHAR`: 'y'
707/// - `G_TYPE_INT`: 'i', 'n'
708/// - `G_TYPE_UINT`: 'u', 'q'
709/// - `G_TYPE_INT64`: 'x'
710/// - `G_TYPE_UINT64`: 't'
711/// - `G_TYPE_DOUBLE`: 'd'
712/// - `G_TYPE_VARIANT`: Any #GVariantType
713///
714/// This can fail if e.g. @gvalue is of type `G_TYPE_STRING` and @type_
715/// is 'i', i.e. `G_VARIANT_TYPE_INT32`. It will also fail for any #GType
716/// (including e.g. `G_TYPE_OBJECT` and `G_TYPE_BOXED` derived-types) not
717/// in the table above.
718///
719/// Note that if @gvalue is of type `G_TYPE_VARIANT` and its value is
720/// [`None`], the empty #GVariant instance (never [`None`]) for @type_ is
721/// returned (e.g. 0 for scalar types, the empty string for string types,
722/// '/' for object path types, the empty array for any array type and so on).
723///
724/// See the g_dbus_gvariant_to_gvalue() function for how to convert a
725/// #GVariant to a #GValue.
726/// ## `gvalue`
727/// A #GValue to convert to a #GVariant
728/// ## `type_`
729/// A #GVariantType
730///
731/// # Returns
732///
733/// A #GVariant (never floating) of
734///     #GVariantType @type_ holding the data from @gvalue or an empty #GVariant
735///     in case of failure. Free with g_variant_unref().
736#[doc(alias = "g_dbus_gvalue_to_gvariant")]
737pub fn dbus_gvalue_to_gvariant(gvalue: &glib::Value, type_: &glib::VariantTy) -> glib::Variant {
738    unsafe {
739        from_glib_full(ffi::g_dbus_gvalue_to_gvariant(
740            gvalue.to_glib_none().0,
741            type_.to_glib_none().0,
742        ))
743    }
744}
745
746/// Converts a #GVariant to a #GValue. If @value is floating, it is consumed.
747///
748/// The rules specified in the g_dbus_gvalue_to_gvariant() function are
749/// used - this function is essentially its reverse form. So, a #GVariant
750/// containing any basic or string array type will be converted to a #GValue
751/// containing a basic value or string array. Any other #GVariant (handle,
752/// variant, tuple, dict entry) will be converted to a #GValue containing that
753/// #GVariant.
754///
755/// The conversion never fails - a valid #GValue is always returned in
756/// @out_gvalue.
757/// ## `value`
758/// A #GVariant.
759///
760/// # Returns
761///
762///
763/// ## `out_gvalue`
764/// Return location pointing to a zero-filled (uninitialized) #GValue.
765#[doc(alias = "g_dbus_gvariant_to_gvalue")]
766pub fn dbus_gvariant_to_gvalue(value: &glib::Variant) -> glib::Value {
767    unsafe {
768        let mut out_gvalue = glib::Value::uninitialized();
769        ffi::g_dbus_gvariant_to_gvalue(value.to_glib_none().0, out_gvalue.to_glib_none_mut().0);
770        out_gvalue
771    }
772}
773
774/// Checks if @string is a
775/// [D-Bus address](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses).
776///
777/// This doesn't check if @string is actually supported by #GDBusServer
778/// or #GDBusConnection - use g_dbus_is_supported_address() to do more
779/// checks.
780/// ## `string`
781/// A string.
782///
783/// # Returns
784///
785/// [`true`] if @string is a valid D-Bus address, [`false`] otherwise.
786#[doc(alias = "g_dbus_is_address")]
787pub fn dbus_is_address(string: &str) -> bool {
788    unsafe { from_glib(ffi::g_dbus_is_address(string.to_glib_none().0)) }
789}
790
791/// Check whether @string is a valid D-Bus error name.
792///
793/// This function returns the same result as g_dbus_is_interface_name(),
794/// because D-Bus error names are defined to have exactly the
795/// same syntax as interface names.
796/// ## `string`
797/// The string to check.
798///
799/// # Returns
800///
801/// [`true`] if valid, [`false`] otherwise.
802#[cfg(feature = "v2_70")]
803#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
804#[doc(alias = "g_dbus_is_error_name")]
805pub fn dbus_is_error_name(string: &str) -> bool {
806    unsafe { from_glib(ffi::g_dbus_is_error_name(string.to_glib_none().0)) }
807}
808
809/// Checks if @string is a D-Bus GUID.
810///
811/// See the documentation for g_dbus_generate_guid() for more information about
812/// the format of a GUID.
813/// ## `string`
814/// The string to check.
815///
816/// # Returns
817///
818/// [`true`] if @string is a GUID, [`false`] otherwise.
819#[doc(alias = "g_dbus_is_guid")]
820pub fn dbus_is_guid(string: &str) -> bool {
821    unsafe { from_glib(ffi::g_dbus_is_guid(string.to_glib_none().0)) }
822}
823
824/// Checks if @string is a valid D-Bus interface name.
825/// ## `string`
826/// The string to check.
827///
828/// # Returns
829///
830/// [`true`] if valid, [`false`] otherwise.
831#[doc(alias = "g_dbus_is_interface_name")]
832pub fn dbus_is_interface_name(string: &str) -> bool {
833    unsafe { from_glib(ffi::g_dbus_is_interface_name(string.to_glib_none().0)) }
834}
835
836/// Checks if @string is a valid D-Bus member (e.g. signal or method) name.
837/// ## `string`
838/// The string to check.
839///
840/// # Returns
841///
842/// [`true`] if valid, [`false`] otherwise.
843#[doc(alias = "g_dbus_is_member_name")]
844pub fn dbus_is_member_name(string: &str) -> bool {
845    unsafe { from_glib(ffi::g_dbus_is_member_name(string.to_glib_none().0)) }
846}
847
848/// Checks if @string is a valid D-Bus bus name (either unique or well-known).
849/// ## `string`
850/// The string to check.
851///
852/// # Returns
853///
854/// [`true`] if valid, [`false`] otherwise.
855#[doc(alias = "g_dbus_is_name")]
856pub fn dbus_is_name(string: &str) -> bool {
857    unsafe { from_glib(ffi::g_dbus_is_name(string.to_glib_none().0)) }
858}
859
860/// Like g_dbus_is_address() but also checks if the library supports the
861/// transports in @string and that key/value pairs for each transport
862/// are valid. See the specification of the
863/// [D-Bus address format](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses).
864/// ## `string`
865/// A string.
866///
867/// # Returns
868///
869/// [`true`] if @string is a valid D-Bus address that is
870/// supported by this library, [`false`] if @error is set.
871#[doc(alias = "g_dbus_is_supported_address")]
872pub fn dbus_is_supported_address(string: &str) -> Result<(), glib::Error> {
873    unsafe {
874        let mut error = std::ptr::null_mut();
875        let is_ok = ffi::g_dbus_is_supported_address(string.to_glib_none().0, &mut error);
876        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
877        if error.is_null() {
878            Ok(())
879        } else {
880            Err(from_glib_full(error))
881        }
882    }
883}
884
885/// Checks if @string is a valid D-Bus unique bus name.
886/// ## `string`
887/// The string to check.
888///
889/// # Returns
890///
891/// [`true`] if valid, [`false`] otherwise.
892#[doc(alias = "g_dbus_is_unique_name")]
893pub fn dbus_is_unique_name(string: &str) -> bool {
894    unsafe { from_glib(ffi::g_dbus_is_unique_name(string.to_glib_none().0)) }
895}
896
897/// Converts `errno.h` error codes into GIO error codes.
898///
899/// The fallback value [`IOErrorEnum::Failed`][crate::IOErrorEnum::Failed] is returned for error codes not
900/// currently handled (but note that future GLib releases may return a more
901/// specific value instead).
902///
903/// As `errno` is global and may be modified by intermediate function
904/// calls, you should save its value immediately after the call returns,
905/// and use the saved value instead of `errno`:
906///
907///
908///
909///
910/// **⚠️ The following code is in C ⚠️**
911///
912/// ```C
913///   int saved_errno;
914///
915///   ret = read (blah);
916///   saved_errno = errno;
917///
918///   g_io_error_from_errno (saved_errno);
919/// ```
920/// ## `err_no`
921/// Error number as defined in errno.h.
922///
923/// # Returns
924///
925/// #GIOErrorEnum value for the given `errno.h` error number
926#[doc(alias = "g_io_error_from_errno")]
927pub fn io_error_from_errno(err_no: i32) -> IOErrorEnum {
928    unsafe { from_glib(ffi::g_io_error_from_errno(err_no)) }
929}
930
931//#[doc(alias = "g_io_modules_load_all_in_directory")]
932//pub fn io_modules_load_all_in_directory(dirname: impl AsRef<std::path::Path>) -> /*Ignored*/Vec<IOModule> {
933//    unsafe { TODO: call ffi:g_io_modules_load_all_in_directory() }
934//}
935
936//#[doc(alias = "g_io_modules_load_all_in_directory_with_scope")]
937//pub fn io_modules_load_all_in_directory_with_scope(dirname: impl AsRef<std::path::Path>, scope: /*Ignored*/&mut IOModuleScope) -> /*Ignored*/Vec<IOModule> {
938//    unsafe { TODO: call ffi:g_io_modules_load_all_in_directory_with_scope() }
939//}
940
941/// Scans all the modules in the specified directory, ensuring that
942/// any extension point implemented by a module is registered.
943///
944/// This may not actually load and initialize all the types in each
945/// module, some modules may be lazily loaded and initialized when
946/// an extension point it implements is used with e.g.
947/// g_io_extension_point_get_extensions() or
948/// g_io_extension_point_get_extension_by_name().
949///
950/// If you need to guarantee that all types are loaded in all the modules,
951/// use g_io_modules_load_all_in_directory().
952/// ## `dirname`
953/// pathname for a directory containing modules
954///     to scan.
955#[doc(alias = "g_io_modules_scan_all_in_directory")]
956pub fn io_modules_scan_all_in_directory(dirname: impl AsRef<std::path::Path>) {
957    unsafe {
958        ffi::g_io_modules_scan_all_in_directory(dirname.as_ref().to_glib_none().0);
959    }
960}
961
962//#[doc(alias = "g_io_modules_scan_all_in_directory_with_scope")]
963//pub fn io_modules_scan_all_in_directory_with_scope(dirname: impl AsRef<std::path::Path>, scope: /*Ignored*/&mut IOModuleScope) {
964//    unsafe { TODO: call ffi:g_io_modules_scan_all_in_directory_with_scope() }
965//}
966
967/// Creates a keyfile-backed [`SettingsBackend`][crate::SettingsBackend].
968///
969/// The filename of the keyfile to use is given by @filename.
970///
971/// All settings read to or written from the backend must fall under the
972/// path given in @root_path (which must start and end with a slash and
973/// not contain two consecutive slashes).  @root_path may be `"/"`.
974///
975/// If @root_group is non-`NULL` then it specifies the name of the keyfile
976/// group used for keys that are written directly below @root_path.  For
977/// example, if @root_path is `"/apps/example/"` and @root_group is
978/// `"toplevel"`, then setting the key `"/apps/example/enabled"` to true will
979/// cause the following to appear in the keyfile:
980///
981/// ```text
982/// [toplevel]
983/// enabled=true
984/// ```
985///
986/// If @root_group is `NULL` then it is not permitted to store keys
987/// directly below the @root_path.
988///
989/// For keys not stored directly below @root_path (ie: in a sub-path),
990/// the name of the subpath (with the final slash stripped) is used as
991/// the name of the keyfile group.  To continue the example, if
992/// `"/apps/example/profiles/default/font-size"` were set to
993/// `12` then the following would appear in the keyfile:
994///
995/// ```text
996/// [profiles/default]
997/// font-size=12
998/// ```
999///
1000/// The backend will refuse writes (and return writability as being
1001/// false) for keys outside of @root_path and, in the event that
1002/// @root_group is `NULL`, also for keys directly under @root_path.
1003/// Writes will also be refused if the backend detects that it has the
1004/// inability to rewrite the keyfile (ie: the containing directory is not
1005/// writable).
1006///
1007/// There is no checking done for your key namespace clashing with the
1008/// syntax of the key file format.  For example, if you have `[` or `]`
1009/// characters in your path names or `=` in your key names you may be in
1010/// trouble.
1011///
1012/// The backend reads default values from a keyfile called `defaults` in
1013/// the directory specified by the `GKeyfileSettingsBackend:defaults-dir`
1014/// property, and a list of locked keys from a text file with the name `locks` in
1015/// the same location.
1016/// ## `filename`
1017/// the filename of the keyfile
1018/// ## `root_path`
1019/// the path under which all settings keys appear
1020/// ## `root_group`
1021/// the group name corresponding to @root_path, or
1022///    `NULL` to disallow storing keys directly beneath @root_path
1023///
1024/// # Returns
1025///
1026/// a keyfile-backed [`SettingsBackend`][crate::SettingsBackend]
1027#[doc(alias = "g_keyfile_settings_backend_new")]
1028pub fn keyfile_settings_backend_new(
1029    filename: &str,
1030    root_path: &str,
1031    root_group: Option<&str>,
1032) -> SettingsBackend {
1033    unsafe {
1034        from_glib_full(ffi::g_keyfile_settings_backend_new(
1035            filename.to_glib_none().0,
1036            root_path.to_glib_none().0,
1037            root_group.to_glib_none().0,
1038        ))
1039    }
1040}
1041
1042/// Creates a memory-backed #GSettingsBackend.
1043///
1044/// This backend allows changes to settings, but does not write them
1045/// to any backing storage, so the next time you run your application,
1046/// the memory backend will start out with the default values again.
1047///
1048/// # Returns
1049///
1050/// a newly created #GSettingsBackend
1051#[doc(alias = "g_memory_settings_backend_new")]
1052pub fn memory_settings_backend_new() -> SettingsBackend {
1053    unsafe { from_glib_full(ffi::g_memory_settings_backend_new()) }
1054}
1055
1056/// Creates a readonly #GSettingsBackend.
1057///
1058/// This backend does not allow changes to settings, so all settings
1059/// will always have their default values.
1060///
1061/// # Returns
1062///
1063/// a newly created #GSettingsBackend
1064#[doc(alias = "g_null_settings_backend_new")]
1065pub fn null_settings_backend_new() -> SettingsBackend {
1066    unsafe { from_glib_full(ffi::g_null_settings_backend_new()) }
1067}
1068
1069/// Returns all the names of children at the specified @path in the set of
1070/// globally registered resources.
1071///
1072/// The return result is a `NULL` terminated list of strings which should
1073/// be released with `strfreev()`.
1074///
1075/// @lookup_flags controls the behaviour of the lookup.
1076/// ## `path`
1077/// A path name inside the resource
1078/// ## `lookup_flags`
1079/// A [`ResourceLookupFlags`][crate::ResourceLookupFlags]
1080///
1081/// # Returns
1082///
1083/// an array of constant strings
1084#[doc(alias = "g_resources_enumerate_children")]
1085pub fn resources_enumerate_children(
1086    path: &str,
1087    lookup_flags: ResourceLookupFlags,
1088) -> Result<Vec<glib::GString>, glib::Error> {
1089    unsafe {
1090        let mut error = std::ptr::null_mut();
1091        let ret = ffi::g_resources_enumerate_children(
1092            path.to_glib_none().0,
1093            lookup_flags.into_glib(),
1094            &mut error,
1095        );
1096        if error.is_null() {
1097            Ok(FromGlibPtrContainer::from_glib_full(ret))
1098        } else {
1099            Err(from_glib_full(error))
1100        }
1101    }
1102}
1103
1104/// Looks for a file at the specified @path in the set of
1105/// globally registered resources and if found returns information about it.
1106///
1107/// @lookup_flags controls the behaviour of the lookup.
1108/// ## `path`
1109/// A path name inside the resource
1110/// ## `lookup_flags`
1111/// A [`ResourceLookupFlags`][crate::ResourceLookupFlags]
1112///
1113/// # Returns
1114///
1115/// `TRUE` if the file was found, `FALSE` if there were errors
1116///
1117/// ## `size`
1118/// a location to place the length of the contents of the file,
1119///    or `NULL` if the length is not needed
1120///
1121/// ## `flags`
1122/// a location to place the [`ResourceFlags`][crate::ResourceFlags] about the file,
1123///    or `NULL` if the flags are not needed
1124#[doc(alias = "g_resources_get_info")]
1125pub fn resources_get_info(
1126    path: &str,
1127    lookup_flags: ResourceLookupFlags,
1128) -> Result<(usize, u32), glib::Error> {
1129    unsafe {
1130        let mut size = std::mem::MaybeUninit::uninit();
1131        let mut flags = std::mem::MaybeUninit::uninit();
1132        let mut error = std::ptr::null_mut();
1133        let is_ok = ffi::g_resources_get_info(
1134            path.to_glib_none().0,
1135            lookup_flags.into_glib(),
1136            size.as_mut_ptr(),
1137            flags.as_mut_ptr(),
1138            &mut error,
1139        );
1140        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1141        if error.is_null() {
1142            Ok((size.assume_init(), flags.assume_init()))
1143        } else {
1144            Err(from_glib_full(error))
1145        }
1146    }
1147}
1148
1149/// Returns whether the specified @path in the set of
1150/// globally registered resources has children.
1151/// ## `path`
1152/// A pathname
1153///
1154/// # Returns
1155///
1156/// [`true`] if @patch has children
1157#[cfg(feature = "v2_84")]
1158#[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))]
1159#[doc(alias = "g_resources_has_children")]
1160pub fn resources_has_children(path: &str) -> bool {
1161    unsafe { from_glib(ffi::g_resources_has_children(path.to_glib_none().0)) }
1162}
1163
1164/// Looks for a file at the specified @path in the set of
1165/// globally registered resources and returns a [`glib::Bytes`][crate::glib::Bytes] that
1166/// lets you directly access the data in memory.
1167///
1168/// The data is always followed by a zero byte, so you
1169/// can safely use the data as a C string. However, that byte
1170/// is not included in the size of the [`glib::Bytes`][crate::glib::Bytes].
1171///
1172/// For uncompressed resource files this is a pointer directly into
1173/// the resource bundle, which is typically in some read-only data section
1174/// in the program binary. For compressed files we allocate memory on
1175/// the heap and automatically uncompress the data.
1176///
1177/// @lookup_flags controls the behaviour of the lookup.
1178/// ## `path`
1179/// A path name inside the resource
1180/// ## `lookup_flags`
1181/// A [`ResourceLookupFlags`][crate::ResourceLookupFlags]
1182///
1183/// # Returns
1184///
1185/// [`glib::Bytes`][crate::glib::Bytes] or `NULL` on error
1186#[doc(alias = "g_resources_lookup_data")]
1187pub fn resources_lookup_data(
1188    path: &str,
1189    lookup_flags: ResourceLookupFlags,
1190) -> Result<glib::Bytes, glib::Error> {
1191    unsafe {
1192        let mut error = std::ptr::null_mut();
1193        let ret = ffi::g_resources_lookup_data(
1194            path.to_glib_none().0,
1195            lookup_flags.into_glib(),
1196            &mut error,
1197        );
1198        if error.is_null() {
1199            Ok(from_glib_full(ret))
1200        } else {
1201            Err(from_glib_full(error))
1202        }
1203    }
1204}
1205
1206/// Looks for a file at the specified @path in the set of
1207/// globally registered resources and returns a [`InputStream`][crate::InputStream]
1208/// that lets you read the data.
1209///
1210/// @lookup_flags controls the behaviour of the lookup.
1211/// ## `path`
1212/// A path name inside the resource
1213/// ## `lookup_flags`
1214/// A [`ResourceLookupFlags`][crate::ResourceLookupFlags]
1215///
1216/// # Returns
1217///
1218/// [`InputStream`][crate::InputStream] or `NULL` on error
1219#[doc(alias = "g_resources_open_stream")]
1220pub fn resources_open_stream(
1221    path: &str,
1222    lookup_flags: ResourceLookupFlags,
1223) -> Result<InputStream, glib::Error> {
1224    unsafe {
1225        let mut error = std::ptr::null_mut();
1226        let ret = ffi::g_resources_open_stream(
1227            path.to_glib_none().0,
1228            lookup_flags.into_glib(),
1229            &mut error,
1230        );
1231        if error.is_null() {
1232            Ok(from_glib_full(ret))
1233        } else {
1234            Err(from_glib_full(error))
1235        }
1236    }
1237}
1238
1239/// Registers the resource with the process-global set of resources.
1240///
1241/// Once a resource is registered the files in it can be accessed
1242/// with the global resource lookup functions like
1243/// [`resources_lookup_data()`][crate::resources_lookup_data()].
1244/// ## `resource`
1245/// A [`Resource`][crate::Resource]
1246#[doc(alias = "g_resources_register")]
1247pub fn resources_register(resource: &Resource) {
1248    unsafe {
1249        ffi::g_resources_register(resource.to_glib_none().0);
1250    }
1251}
1252
1253/// Unregisters the resource from the process-global set of resources.
1254/// ## `resource`
1255/// A [`Resource`][crate::Resource]
1256#[doc(alias = "g_resources_unregister")]
1257pub fn resources_unregister(resource: &Resource) {
1258    unsafe {
1259        ffi::g_resources_unregister(resource.to_glib_none().0);
1260    }
1261}
1262
1263/// Determines if @mount_path is considered an implementation of the
1264/// OS.
1265///
1266/// This is primarily used for hiding mountable and mounted volumes
1267/// that only are used in the OS and has little to no relevance to the
1268/// casual user.
1269/// ## `mount_path`
1270/// a mount path, e.g. `/media/disk` or `/usr`
1271///
1272/// # Returns
1273///
1274/// true if @mount_path is considered an implementation detail
1275///    of the OS; false otherwise
1276#[cfg(unix)]
1277#[cfg_attr(docsrs, doc(cfg(unix)))]
1278#[doc(alias = "g_unix_is_mount_path_system_internal")]
1279pub fn unix_is_mount_path_system_internal(mount_path: impl AsRef<std::path::Path>) -> bool {
1280    unsafe {
1281        from_glib(ffi::g_unix_is_mount_path_system_internal(
1282            mount_path.as_ref().to_glib_none().0,
1283        ))
1284    }
1285}
1286
1287/// Determines if @device_path is considered a block device path which is only
1288/// used in implementation of the OS.
1289///
1290/// This is primarily used for hiding mounted volumes that are intended as APIs
1291/// for programs to read, and system administrators at a shell; rather than
1292/// something that should, for example, appear in a GUI. For example, the Linux
1293/// `/proc` filesystem.
1294///
1295/// The list of device paths considered ‘system’ ones may change over time.
1296/// ## `device_path`
1297/// a device path, e.g. `/dev/loop0` or `nfsd`
1298///
1299/// # Returns
1300///
1301/// true if @device_path is considered an implementation detail of
1302///    the OS; false otherwise
1303#[cfg(unix)]
1304#[cfg_attr(docsrs, doc(cfg(unix)))]
1305#[doc(alias = "g_unix_is_system_device_path")]
1306pub fn unix_is_system_device_path(device_path: impl AsRef<std::path::Path>) -> bool {
1307    unsafe {
1308        from_glib(ffi::g_unix_is_system_device_path(
1309            device_path.as_ref().to_glib_none().0,
1310        ))
1311    }
1312}
1313
1314/// Determines if @fs_type is considered a type of file system which is only
1315/// used in implementation of the OS.
1316///
1317/// This is primarily used for hiding mounted volumes that are intended as APIs
1318/// for programs to read, and system administrators at a shell; rather than
1319/// something that should, for example, appear in a GUI. For example, the Linux
1320/// `/proc` filesystem.
1321///
1322/// The list of file system types considered ‘system’ ones may change over time.
1323/// ## `fs_type`
1324/// a file system type, e.g. `procfs` or `tmpfs`
1325///
1326/// # Returns
1327///
1328/// true if @fs_type is considered an implementation detail of the OS;
1329///    false otherwise
1330#[cfg(unix)]
1331#[cfg_attr(docsrs, doc(cfg(unix)))]
1332#[doc(alias = "g_unix_is_system_fs_type")]
1333pub fn unix_is_system_fs_type(fs_type: &str) -> bool {
1334    unsafe { from_glib(ffi::g_unix_is_system_fs_type(fs_type.to_glib_none().0)) }
1335}