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