gio/auto/
file.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "futures")]
6use futures::future;
7use gio_sys;
8use glib;
9use glib::object::IsA;
10use glib::translate::*;
11use glib::GString;
12use glib_sys;
13use gobject_sys;
14use std;
15use std::boxed::Box as Box_;
16use std::fmt;
17use std::mem;
18use std::ptr;
19use AppInfo;
20use Cancellable;
21use DriveStartFlags;
22use Error;
23use FileCopyFlags;
24use FileCreateFlags;
25use FileIOStream;
26use FileInfo;
27use FileInputStream;
28use FileMeasureFlags;
29use FileMonitor;
30use FileMonitorFlags;
31use FileOutputStream;
32use FileQueryInfoFlags;
33use FileType;
34use Mount;
35use MountMountFlags;
36use MountOperation;
37use MountUnmountFlags;
38
39glib_wrapper! {
40    pub struct File(Interface<gio_sys::GFile>);
41
42    match fn {
43        get_type => || gio_sys::g_file_get_type(),
44    }
45}
46
47impl File {
48    //#[cfg(any(feature = "v2_56", feature = "dox"))]
49    //pub fn new_build_filename<P: AsRef<std::path::Path>>(first_element: P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<File> {
50    //    unsafe { TODO: call gio_sys:g_file_new_build_filename() }
51    //}
52
53    pub fn new_for_commandline_arg<P: AsRef<std::ffi::OsStr>>(arg: P) -> File {
54        unsafe {
55            from_glib_full(gio_sys::g_file_new_for_commandline_arg(
56                arg.as_ref().to_glib_none().0,
57            ))
58        }
59    }
60
61    pub fn new_for_commandline_arg_and_cwd<P: AsRef<std::ffi::OsStr>, Q: AsRef<std::path::Path>>(
62        arg: P,
63        cwd: Q,
64    ) -> File {
65        unsafe {
66            from_glib_full(gio_sys::g_file_new_for_commandline_arg_and_cwd(
67                arg.as_ref().to_glib_none().0,
68                cwd.as_ref().to_glib_none().0,
69            ))
70        }
71    }
72
73    pub fn new_for_path<P: AsRef<std::path::Path>>(path: P) -> File {
74        unsafe { from_glib_full(gio_sys::g_file_new_for_path(path.as_ref().to_glib_none().0)) }
75    }
76
77    pub fn new_for_uri(uri: &str) -> File {
78        unsafe { from_glib_full(gio_sys::g_file_new_for_uri(uri.to_glib_none().0)) }
79    }
80
81    pub fn new_tmp<P: AsRef<std::path::Path>>(tmpl: P) -> Result<(File, FileIOStream), Error> {
82        unsafe {
83            let mut iostream = ptr::null_mut();
84            let mut error = ptr::null_mut();
85            let ret =
86                gio_sys::g_file_new_tmp(tmpl.as_ref().to_glib_none().0, &mut iostream, &mut error);
87            if error.is_null() {
88                Ok((from_glib_full(ret), from_glib_full(iostream)))
89            } else {
90                Err(from_glib_full(error))
91            }
92        }
93    }
94
95    pub fn parse_name(parse_name: &str) -> Option<File> {
96        unsafe { from_glib_full(gio_sys::g_file_parse_name(parse_name.to_glib_none().0)) }
97    }
98}
99
100unsafe impl Send for File {}
101unsafe impl Sync for File {}
102
103pub const NONE_FILE: Option<&File> = None;
104
105pub trait FileExt: 'static {
106    fn append_to<P: IsA<Cancellable>>(
107        &self,
108        flags: FileCreateFlags,
109        cancellable: Option<&P>,
110    ) -> Result<FileOutputStream, Error>;
111
112    fn append_to_async<
113        P: IsA<Cancellable>,
114        Q: FnOnce(Result<FileOutputStream, Error>) + Send + 'static,
115    >(
116        &self,
117        flags: FileCreateFlags,
118        io_priority: glib::Priority,
119        cancellable: Option<&P>,
120        callback: Q,
121    );
122
123    #[cfg(feature = "futures")]
124    fn append_to_async_future(
125        &self,
126        flags: FileCreateFlags,
127        io_priority: glib::Priority,
128    ) -> Box_<dyn future::Future<Output = Result<FileOutputStream, Error>> + std::marker::Unpin>;
129
130    fn copy<P: IsA<File>, Q: IsA<Cancellable>>(
131        &self,
132        destination: &P,
133        flags: FileCopyFlags,
134        cancellable: Option<&Q>,
135        progress_callback: Option<&mut dyn (FnMut(i64, i64))>,
136    ) -> Result<(), Error>;
137
138    //fn copy_async<P: IsA<File>, Q: IsA<Cancellable>, R: FnOnce(Result<(), Error>) + Send + 'static, S: FnOnce(Result<(), Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, cancellable: Option<&Q>, progress_callback: R, callback: S);
139
140    //#[cfg(feature = "futures")]
141    //fn copy_async_future<P: IsA<File> + Clone + 'static, R: FnOnce(Result<(), Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, progress_callback: R) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin>;
142
143    fn copy_attributes<P: IsA<File>, Q: IsA<Cancellable>>(
144        &self,
145        destination: &P,
146        flags: FileCopyFlags,
147        cancellable: Option<&Q>,
148    ) -> Result<(), Error>;
149
150    fn create<P: IsA<Cancellable>>(
151        &self,
152        flags: FileCreateFlags,
153        cancellable: Option<&P>,
154    ) -> Result<FileOutputStream, Error>;
155
156    fn create_async<
157        P: IsA<Cancellable>,
158        Q: FnOnce(Result<FileOutputStream, Error>) + Send + 'static,
159    >(
160        &self,
161        flags: FileCreateFlags,
162        io_priority: glib::Priority,
163        cancellable: Option<&P>,
164        callback: Q,
165    );
166
167    #[cfg(feature = "futures")]
168    fn create_async_future(
169        &self,
170        flags: FileCreateFlags,
171        io_priority: glib::Priority,
172    ) -> Box_<dyn future::Future<Output = Result<FileOutputStream, Error>> + std::marker::Unpin>;
173
174    fn create_readwrite<P: IsA<Cancellable>>(
175        &self,
176        flags: FileCreateFlags,
177        cancellable: Option<&P>,
178    ) -> Result<FileIOStream, Error>;
179
180    fn create_readwrite_async<
181        P: IsA<Cancellable>,
182        Q: FnOnce(Result<FileIOStream, Error>) + Send + 'static,
183    >(
184        &self,
185        flags: FileCreateFlags,
186        io_priority: glib::Priority,
187        cancellable: Option<&P>,
188        callback: Q,
189    );
190
191    #[cfg(feature = "futures")]
192    fn create_readwrite_async_future(
193        &self,
194        flags: FileCreateFlags,
195        io_priority: glib::Priority,
196    ) -> Box_<dyn future::Future<Output = Result<FileIOStream, Error>> + std::marker::Unpin>;
197
198    fn delete<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), Error>;
199
200    fn delete_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
201        &self,
202        io_priority: glib::Priority,
203        cancellable: Option<&P>,
204        callback: Q,
205    );
206
207    #[cfg(feature = "futures")]
208    fn delete_async_future(
209        &self,
210        io_priority: glib::Priority,
211    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin>;
212
213    fn dup(&self) -> Option<File>;
214
215    fn eject_mountable_with_operation<
216        P: IsA<MountOperation>,
217        Q: IsA<Cancellable>,
218        R: FnOnce(Result<(), Error>) + Send + 'static,
219    >(
220        &self,
221        flags: MountUnmountFlags,
222        mount_operation: Option<&P>,
223        cancellable: Option<&Q>,
224        callback: R,
225    );
226
227    #[cfg(feature = "futures")]
228    fn eject_mountable_with_operation_future<P: IsA<MountOperation> + Clone + 'static>(
229        &self,
230        flags: MountUnmountFlags,
231        mount_operation: Option<&P>,
232    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin>;
233
234    //fn enumerate_children<P: IsA<Cancellable>>(&self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>) -> Result</*Ignored*/FileEnumerator, Error>;
235
236    fn equal<P: IsA<File>>(&self, file2: &P) -> bool;
237
238    fn find_enclosing_mount<P: IsA<Cancellable>>(
239        &self,
240        cancellable: Option<&P>,
241    ) -> Result<Mount, Error>;
242
243    fn get_basename(&self) -> Option<std::path::PathBuf>;
244
245    fn get_child<P: AsRef<std::path::Path>>(&self, name: P) -> Option<File>;
246
247    fn get_child_for_display_name(&self, display_name: &str) -> Result<File, Error>;
248
249    fn get_parent(&self) -> Option<File>;
250
251    fn get_parse_name(&self) -> Option<GString>;
252
253    fn get_path(&self) -> Option<std::path::PathBuf>;
254
255    fn get_relative_path<P: IsA<File>>(&self, descendant: &P) -> Option<std::path::PathBuf>;
256
257    fn get_uri(&self) -> GString;
258
259    fn get_uri_scheme(&self) -> GString;
260
261    fn has_parent<P: IsA<File>>(&self, parent: Option<&P>) -> bool;
262
263    fn has_prefix<P: IsA<File>>(&self, prefix: &P) -> bool;
264
265    fn has_uri_scheme(&self, uri_scheme: &str) -> bool;
266
267    fn is_native(&self) -> bool;
268
269    #[cfg(any(feature = "v2_56", feature = "dox"))]
270    fn load_bytes<P: IsA<Cancellable>>(
271        &self,
272        cancellable: Option<&P>,
273    ) -> Result<(glib::Bytes, Option<GString>), Error>;
274
275    #[cfg(any(feature = "v2_56", feature = "dox"))]
276    fn load_bytes_async<
277        P: IsA<Cancellable>,
278        Q: FnOnce(Result<(glib::Bytes, GString), Error>) + Send + 'static,
279    >(
280        &self,
281        cancellable: Option<&P>,
282        callback: Q,
283    );
284
285    #[cfg(feature = "futures")]
286    #[cfg(any(feature = "v2_56", feature = "dox"))]
287    fn load_bytes_async_future(
288        &self,
289    ) -> Box_<dyn future::Future<Output = Result<(glib::Bytes, GString), Error>> + std::marker::Unpin>;
290
291    fn load_contents<P: IsA<Cancellable>>(
292        &self,
293        cancellable: Option<&P>,
294    ) -> Result<(Vec<u8>, GString), Error>;
295
296    fn load_contents_async<
297        P: IsA<Cancellable>,
298        Q: FnOnce(Result<(Vec<u8>, GString), Error>) + Send + 'static,
299    >(
300        &self,
301        cancellable: Option<&P>,
302        callback: Q,
303    );
304
305    #[cfg(feature = "futures")]
306    fn load_contents_async_future(
307        &self,
308    ) -> Box_<dyn future::Future<Output = Result<(Vec<u8>, GString), Error>> + std::marker::Unpin>;
309
310    //fn load_partial_contents_async<P: IsA<Cancellable>, Q: FnOnce(Result<(Vec<u8>, GString), Error>) + Send + 'static, R: FnOnce(Result<(Vec<u8>, GString), Error>) + Send + 'static>(&self, cancellable: Option<&P>, read_more_callback: Q, callback: R);
311
312    //#[cfg(feature = "futures")]
313    //fn load_partial_contents_async_future<Q: FnOnce(Result<(Vec<u8>, GString), Error>) + Send + 'static>(&self, read_more_callback: Q) -> Box_<dyn future::Future<Output = Result<(Vec<u8>, GString), Error>> + std::marker::Unpin>;
314
315    fn make_directory<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), Error>;
316
317    fn make_directory_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
318        &self,
319        io_priority: glib::Priority,
320        cancellable: Option<&P>,
321        callback: Q,
322    );
323
324    #[cfg(feature = "futures")]
325    fn make_directory_async_future(
326        &self,
327        io_priority: glib::Priority,
328    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin>;
329
330    fn make_directory_with_parents<P: IsA<Cancellable>>(
331        &self,
332        cancellable: Option<&P>,
333    ) -> Result<(), Error>;
334
335    fn make_symbolic_link<P: AsRef<std::path::Path>, Q: IsA<Cancellable>>(
336        &self,
337        symlink_value: P,
338        cancellable: Option<&Q>,
339    ) -> Result<(), Error>;
340
341    fn measure_disk_usage<P: IsA<Cancellable>>(
342        &self,
343        flags: FileMeasureFlags,
344        cancellable: Option<&P>,
345        progress_callback: Option<Box<dyn Fn(bool, u64, u64, u64) + 'static>>,
346    ) -> Result<(u64, u64, u64), Error>;
347
348    //fn measure_disk_usage_async<P: IsA<Cancellable>, Q: FnOnce(Result<(u64, u64, u64), Error>) + Send + 'static, R: FnOnce(Result<(u64, u64, u64), Error>) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, cancellable: Option<&P>, progress_callback: Q, callback: R);
349
350    //#[cfg(feature = "futures")]
351    //fn measure_disk_usage_async_future<Q: FnOnce(Result<(u64, u64, u64), Error>) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, progress_callback: Q) -> Box_<dyn future::Future<Output = Result<(u64, u64, u64), Error>> + std::marker::Unpin>;
352
353    fn monitor<P: IsA<Cancellable>>(
354        &self,
355        flags: FileMonitorFlags,
356        cancellable: Option<&P>,
357    ) -> Result<FileMonitor, Error>;
358
359    fn monitor_directory<P: IsA<Cancellable>>(
360        &self,
361        flags: FileMonitorFlags,
362        cancellable: Option<&P>,
363    ) -> Result<FileMonitor, Error>;
364
365    fn monitor_file<P: IsA<Cancellable>>(
366        &self,
367        flags: FileMonitorFlags,
368        cancellable: Option<&P>,
369    ) -> Result<FileMonitor, Error>;
370
371    fn mount_enclosing_volume<
372        P: IsA<MountOperation>,
373        Q: IsA<Cancellable>,
374        R: FnOnce(Result<(), Error>) + Send + 'static,
375    >(
376        &self,
377        flags: MountMountFlags,
378        mount_operation: Option<&P>,
379        cancellable: Option<&Q>,
380        callback: R,
381    );
382
383    #[cfg(feature = "futures")]
384    fn mount_enclosing_volume_future<P: IsA<MountOperation> + Clone + 'static>(
385        &self,
386        flags: MountMountFlags,
387        mount_operation: Option<&P>,
388    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin>;
389
390    fn mount_mountable<
391        P: IsA<MountOperation>,
392        Q: IsA<Cancellable>,
393        R: FnOnce(Result<File, Error>) + Send + 'static,
394    >(
395        &self,
396        flags: MountMountFlags,
397        mount_operation: Option<&P>,
398        cancellable: Option<&Q>,
399        callback: R,
400    );
401
402    #[cfg(feature = "futures")]
403    fn mount_mountable_future<P: IsA<MountOperation> + Clone + 'static>(
404        &self,
405        flags: MountMountFlags,
406        mount_operation: Option<&P>,
407    ) -> Box_<dyn future::Future<Output = Result<File, Error>> + std::marker::Unpin>;
408
409    fn move_<P: IsA<File>, Q: IsA<Cancellable>>(
410        &self,
411        destination: &P,
412        flags: FileCopyFlags,
413        cancellable: Option<&Q>,
414        progress_callback: Option<&mut dyn (FnMut(i64, i64))>,
415    ) -> Result<(), Error>;
416
417    fn open_readwrite<P: IsA<Cancellable>>(
418        &self,
419        cancellable: Option<&P>,
420    ) -> Result<FileIOStream, Error>;
421
422    fn open_readwrite_async<
423        P: IsA<Cancellable>,
424        Q: FnOnce(Result<FileIOStream, Error>) + Send + 'static,
425    >(
426        &self,
427        io_priority: glib::Priority,
428        cancellable: Option<&P>,
429        callback: Q,
430    );
431
432    #[cfg(feature = "futures")]
433    fn open_readwrite_async_future(
434        &self,
435        io_priority: glib::Priority,
436    ) -> Box_<dyn future::Future<Output = Result<FileIOStream, Error>> + std::marker::Unpin>;
437
438    #[cfg(any(feature = "v2_56", feature = "dox"))]
439    fn peek_path(&self) -> Option<std::path::PathBuf>;
440
441    fn poll_mountable<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
442        &self,
443        cancellable: Option<&P>,
444        callback: Q,
445    );
446
447    #[cfg(feature = "futures")]
448    fn poll_mountable_future(
449        &self,
450    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin>;
451
452    fn query_default_handler<P: IsA<Cancellable>>(
453        &self,
454        cancellable: Option<&P>,
455    ) -> Result<AppInfo, Error>;
456
457    fn query_exists<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> bool;
458
459    fn query_file_type<P: IsA<Cancellable>>(
460        &self,
461        flags: FileQueryInfoFlags,
462        cancellable: Option<&P>,
463    ) -> FileType;
464
465    fn query_filesystem_info<P: IsA<Cancellable>>(
466        &self,
467        attributes: &str,
468        cancellable: Option<&P>,
469    ) -> Result<FileInfo, Error>;
470
471    fn query_filesystem_info_async<
472        P: IsA<Cancellable>,
473        Q: FnOnce(Result<FileInfo, Error>) + Send + 'static,
474    >(
475        &self,
476        attributes: &str,
477        io_priority: glib::Priority,
478        cancellable: Option<&P>,
479        callback: Q,
480    );
481
482    #[cfg(feature = "futures")]
483    fn query_filesystem_info_async_future(
484        &self,
485        attributes: &str,
486        io_priority: glib::Priority,
487    ) -> Box_<dyn future::Future<Output = Result<FileInfo, Error>> + std::marker::Unpin>;
488
489    fn query_info<P: IsA<Cancellable>>(
490        &self,
491        attributes: &str,
492        flags: FileQueryInfoFlags,
493        cancellable: Option<&P>,
494    ) -> Result<FileInfo, Error>;
495
496    fn query_info_async<P: IsA<Cancellable>, Q: FnOnce(Result<FileInfo, Error>) + Send + 'static>(
497        &self,
498        attributes: &str,
499        flags: FileQueryInfoFlags,
500        io_priority: glib::Priority,
501        cancellable: Option<&P>,
502        callback: Q,
503    );
504
505    #[cfg(feature = "futures")]
506    fn query_info_async_future(
507        &self,
508        attributes: &str,
509        flags: FileQueryInfoFlags,
510        io_priority: glib::Priority,
511    ) -> Box_<dyn future::Future<Output = Result<FileInfo, Error>> + std::marker::Unpin>;
512
513    //fn query_settable_attributes<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result</*Ignored*/FileAttributeInfoList, Error>;
514
515    //fn query_writable_namespaces<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result</*Ignored*/FileAttributeInfoList, Error>;
516
517    fn read<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<FileInputStream, Error>;
518
519    fn read_async<P: IsA<Cancellable>, Q: FnOnce(Result<FileInputStream, Error>) + Send + 'static>(
520        &self,
521        io_priority: glib::Priority,
522        cancellable: Option<&P>,
523        callback: Q,
524    );
525
526    #[cfg(feature = "futures")]
527    fn read_async_future(
528        &self,
529        io_priority: glib::Priority,
530    ) -> Box_<dyn future::Future<Output = Result<FileInputStream, Error>> + std::marker::Unpin>;
531
532    fn replace<P: IsA<Cancellable>>(
533        &self,
534        etag: Option<&str>,
535        make_backup: bool,
536        flags: FileCreateFlags,
537        cancellable: Option<&P>,
538    ) -> Result<FileOutputStream, Error>;
539
540    fn replace_async<
541        P: IsA<Cancellable>,
542        Q: FnOnce(Result<FileOutputStream, Error>) + Send + 'static,
543    >(
544        &self,
545        etag: Option<&str>,
546        make_backup: bool,
547        flags: FileCreateFlags,
548        io_priority: glib::Priority,
549        cancellable: Option<&P>,
550        callback: Q,
551    );
552
553    #[cfg(feature = "futures")]
554    fn replace_async_future(
555        &self,
556        etag: Option<&str>,
557        make_backup: bool,
558        flags: FileCreateFlags,
559        io_priority: glib::Priority,
560    ) -> Box_<dyn future::Future<Output = Result<FileOutputStream, Error>> + std::marker::Unpin>;
561
562    fn replace_contents<P: IsA<Cancellable>>(
563        &self,
564        contents: &[u8],
565        etag: Option<&str>,
566        make_backup: bool,
567        flags: FileCreateFlags,
568        cancellable: Option<&P>,
569    ) -> Result<GString, Error>;
570
571    //fn replace_contents_bytes_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + 'static>(&self, contents: &glib::Bytes, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, callback: Q);
572
573    fn replace_readwrite<P: IsA<Cancellable>>(
574        &self,
575        etag: Option<&str>,
576        make_backup: bool,
577        flags: FileCreateFlags,
578        cancellable: Option<&P>,
579    ) -> Result<FileIOStream, Error>;
580
581    fn replace_readwrite_async<
582        P: IsA<Cancellable>,
583        Q: FnOnce(Result<FileIOStream, Error>) + Send + 'static,
584    >(
585        &self,
586        etag: Option<&str>,
587        make_backup: bool,
588        flags: FileCreateFlags,
589        io_priority: glib::Priority,
590        cancellable: Option<&P>,
591        callback: Q,
592    );
593
594    #[cfg(feature = "futures")]
595    fn replace_readwrite_async_future(
596        &self,
597        etag: Option<&str>,
598        make_backup: bool,
599        flags: FileCreateFlags,
600        io_priority: glib::Priority,
601    ) -> Box_<dyn future::Future<Output = Result<FileIOStream, Error>> + std::marker::Unpin>;
602
603    fn resolve_relative_path<P: AsRef<std::path::Path>>(&self, relative_path: P) -> Option<File>;
604
605    //fn set_attribute<P: IsA<Cancellable>>(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Option<Fundamental: Pointer>, flags: FileQueryInfoFlags, cancellable: Option<&P>) -> Result<(), Error>;
606
607    fn set_attribute_byte_string<P: IsA<Cancellable>>(
608        &self,
609        attribute: &str,
610        value: &str,
611        flags: FileQueryInfoFlags,
612        cancellable: Option<&P>,
613    ) -> Result<(), Error>;
614
615    fn set_attribute_int32<P: IsA<Cancellable>>(
616        &self,
617        attribute: &str,
618        value: i32,
619        flags: FileQueryInfoFlags,
620        cancellable: Option<&P>,
621    ) -> Result<(), Error>;
622
623    fn set_attribute_int64<P: IsA<Cancellable>>(
624        &self,
625        attribute: &str,
626        value: i64,
627        flags: FileQueryInfoFlags,
628        cancellable: Option<&P>,
629    ) -> Result<(), Error>;
630
631    fn set_attribute_string<P: IsA<Cancellable>>(
632        &self,
633        attribute: &str,
634        value: &str,
635        flags: FileQueryInfoFlags,
636        cancellable: Option<&P>,
637    ) -> Result<(), Error>;
638
639    fn set_attribute_uint32<P: IsA<Cancellable>>(
640        &self,
641        attribute: &str,
642        value: u32,
643        flags: FileQueryInfoFlags,
644        cancellable: Option<&P>,
645    ) -> Result<(), Error>;
646
647    fn set_attribute_uint64<P: IsA<Cancellable>>(
648        &self,
649        attribute: &str,
650        value: u64,
651        flags: FileQueryInfoFlags,
652        cancellable: Option<&P>,
653    ) -> Result<(), Error>;
654
655    fn set_attributes_async<
656        P: IsA<Cancellable>,
657        Q: FnOnce(Result<FileInfo, Error>) + Send + 'static,
658    >(
659        &self,
660        info: &FileInfo,
661        flags: FileQueryInfoFlags,
662        io_priority: glib::Priority,
663        cancellable: Option<&P>,
664        callback: Q,
665    );
666
667    #[cfg(feature = "futures")]
668    fn set_attributes_async_future(
669        &self,
670        info: &FileInfo,
671        flags: FileQueryInfoFlags,
672        io_priority: glib::Priority,
673    ) -> Box_<dyn future::Future<Output = Result<FileInfo, Error>> + std::marker::Unpin>;
674
675    fn set_attributes_from_info<P: IsA<Cancellable>>(
676        &self,
677        info: &FileInfo,
678        flags: FileQueryInfoFlags,
679        cancellable: Option<&P>,
680    ) -> Result<(), Error>;
681
682    fn set_display_name<P: IsA<Cancellable>>(
683        &self,
684        display_name: &str,
685        cancellable: Option<&P>,
686    ) -> Result<File, Error>;
687
688    fn set_display_name_async<
689        P: IsA<Cancellable>,
690        Q: FnOnce(Result<File, Error>) + Send + 'static,
691    >(
692        &self,
693        display_name: &str,
694        io_priority: glib::Priority,
695        cancellable: Option<&P>,
696        callback: Q,
697    );
698
699    #[cfg(feature = "futures")]
700    fn set_display_name_async_future(
701        &self,
702        display_name: &str,
703        io_priority: glib::Priority,
704    ) -> Box_<dyn future::Future<Output = Result<File, Error>> + std::marker::Unpin>;
705
706    fn start_mountable<
707        P: IsA<MountOperation>,
708        Q: IsA<Cancellable>,
709        R: FnOnce(Result<(), Error>) + Send + 'static,
710    >(
711        &self,
712        flags: DriveStartFlags,
713        start_operation: Option<&P>,
714        cancellable: Option<&Q>,
715        callback: R,
716    );
717
718    #[cfg(feature = "futures")]
719    fn start_mountable_future<P: IsA<MountOperation> + Clone + 'static>(
720        &self,
721        flags: DriveStartFlags,
722        start_operation: Option<&P>,
723    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin>;
724
725    fn stop_mountable<
726        P: IsA<MountOperation>,
727        Q: IsA<Cancellable>,
728        R: FnOnce(Result<(), Error>) + Send + 'static,
729    >(
730        &self,
731        flags: MountUnmountFlags,
732        mount_operation: Option<&P>,
733        cancellable: Option<&Q>,
734        callback: R,
735    );
736
737    #[cfg(feature = "futures")]
738    fn stop_mountable_future<P: IsA<MountOperation> + Clone + 'static>(
739        &self,
740        flags: MountUnmountFlags,
741        mount_operation: Option<&P>,
742    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin>;
743
744    fn supports_thread_contexts(&self) -> bool;
745
746    fn trash<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), Error>;
747
748    fn trash_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
749        &self,
750        io_priority: glib::Priority,
751        cancellable: Option<&P>,
752        callback: Q,
753    );
754
755    #[cfg(feature = "futures")]
756    fn trash_async_future(
757        &self,
758        io_priority: glib::Priority,
759    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin>;
760
761    fn unmount_mountable_with_operation<
762        P: IsA<MountOperation>,
763        Q: IsA<Cancellable>,
764        R: FnOnce(Result<(), Error>) + Send + 'static,
765    >(
766        &self,
767        flags: MountUnmountFlags,
768        mount_operation: Option<&P>,
769        cancellable: Option<&Q>,
770        callback: R,
771    );
772
773    #[cfg(feature = "futures")]
774    fn unmount_mountable_with_operation_future<P: IsA<MountOperation> + Clone + 'static>(
775        &self,
776        flags: MountUnmountFlags,
777        mount_operation: Option<&P>,
778    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin>;
779}
780
781impl<O: IsA<File>> FileExt for O {
782    fn append_to<P: IsA<Cancellable>>(
783        &self,
784        flags: FileCreateFlags,
785        cancellable: Option<&P>,
786    ) -> Result<FileOutputStream, Error> {
787        unsafe {
788            let mut error = ptr::null_mut();
789            let ret = gio_sys::g_file_append_to(
790                self.as_ref().to_glib_none().0,
791                flags.to_glib(),
792                cancellable.map(|p| p.as_ref()).to_glib_none().0,
793                &mut error,
794            );
795            if error.is_null() {
796                Ok(from_glib_full(ret))
797            } else {
798                Err(from_glib_full(error))
799            }
800        }
801    }
802
803    fn append_to_async<
804        P: IsA<Cancellable>,
805        Q: FnOnce(Result<FileOutputStream, Error>) + Send + 'static,
806    >(
807        &self,
808        flags: FileCreateFlags,
809        io_priority: glib::Priority,
810        cancellable: Option<&P>,
811        callback: Q,
812    ) {
813        let user_data: Box<Q> = Box::new(callback);
814        unsafe extern "C" fn append_to_async_trampoline<
815            Q: FnOnce(Result<FileOutputStream, Error>) + Send + 'static,
816        >(
817            _source_object: *mut gobject_sys::GObject,
818            res: *mut gio_sys::GAsyncResult,
819            user_data: glib_sys::gpointer,
820        ) {
821            let mut error = ptr::null_mut();
822            let ret = gio_sys::g_file_append_to_finish(_source_object as *mut _, res, &mut error);
823            let result = if error.is_null() {
824                Ok(from_glib_full(ret))
825            } else {
826                Err(from_glib_full(error))
827            };
828            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
829            callback(result);
830        }
831        let callback = append_to_async_trampoline::<Q>;
832        unsafe {
833            gio_sys::g_file_append_to_async(
834                self.as_ref().to_glib_none().0,
835                flags.to_glib(),
836                io_priority.to_glib(),
837                cancellable.map(|p| p.as_ref()).to_glib_none().0,
838                Some(callback),
839                Box::into_raw(user_data) as *mut _,
840            );
841        }
842    }
843
844    #[cfg(feature = "futures")]
845    fn append_to_async_future(
846        &self,
847        flags: FileCreateFlags,
848        io_priority: glib::Priority,
849    ) -> Box_<dyn future::Future<Output = Result<FileOutputStream, Error>> + std::marker::Unpin>
850    {
851        use fragile::Fragile;
852        use GioFuture;
853
854        GioFuture::new(self, move |obj, send| {
855            let cancellable = Cancellable::new();
856            let send = Fragile::new(send);
857            obj.append_to_async(flags, io_priority, Some(&cancellable), move |res| {
858                let _ = send.into_inner().send(res);
859            });
860
861            cancellable
862        })
863    }
864
865    fn copy<P: IsA<File>, Q: IsA<Cancellable>>(
866        &self,
867        destination: &P,
868        flags: FileCopyFlags,
869        cancellable: Option<&Q>,
870        progress_callback: Option<&mut dyn (FnMut(i64, i64))>,
871    ) -> Result<(), Error> {
872        let progress_callback_data: Option<&mut dyn (FnMut(i64, i64))> = progress_callback;
873        unsafe extern "C" fn progress_callback_func<P: IsA<File>, Q: IsA<Cancellable>>(
874            current_num_bytes: i64,
875            total_num_bytes: i64,
876            user_data: glib_sys::gpointer,
877        ) {
878            let callback: *mut Option<&mut dyn (FnMut(i64, i64))> =
879                user_data as *const _ as usize as *mut Option<&mut dyn (FnMut(i64, i64))>;
880            if let Some(ref mut callback) = *callback {
881                callback(current_num_bytes, total_num_bytes)
882            } else {
883                panic!("cannot get closure...")
884            };
885        }
886        let progress_callback = if progress_callback_data.is_some() {
887            Some(progress_callback_func::<P, Q> as _)
888        } else {
889            None
890        };
891        let super_callback0: &Option<&mut dyn (FnMut(i64, i64))> = &progress_callback_data;
892        unsafe {
893            let mut error = ptr::null_mut();
894            let _ = gio_sys::g_file_copy(
895                self.as_ref().to_glib_none().0,
896                destination.as_ref().to_glib_none().0,
897                flags.to_glib(),
898                cancellable.map(|p| p.as_ref()).to_glib_none().0,
899                progress_callback,
900                super_callback0 as *const _ as usize as *mut _,
901                &mut error,
902            );
903            if error.is_null() {
904                Ok(())
905            } else {
906                Err(from_glib_full(error))
907            }
908        }
909    }
910
911    //fn copy_async<P: IsA<File>, Q: IsA<Cancellable>, R: FnOnce(Result<(), Error>) + Send + 'static, S: FnOnce(Result<(), Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, cancellable: Option<&Q>, progress_callback: R, callback: S) {
912    //    unsafe { TODO: call gio_sys:g_file_copy_async() }
913    //}
914
915    //#[cfg(feature = "futures")]
916    //fn copy_async_future<P: IsA<File> + Clone + 'static, R: FnOnce(Result<(), Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, progress_callback: R) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
917    //use GioFuture;
918    //use fragile::Fragile;
919
920    //let destination = destination.clone();
921    //let progress_callback = progress_callback.map(ToOwned::to_owned);
922    //GioFuture::new(self, move |obj, send| {
923    //    let cancellable = Cancellable::new();
924    //    let send = Fragile::new(send);
925    //    obj.copy_async(
926    //        &destination,
927    //        flags,
928    //        io_priority,
929    //        Some(&cancellable),
930    //        progress_callback.as_ref().map(::std::borrow::Borrow::borrow),
931    //        move |res| {
932    //            let _ = send.into_inner().send(res);
933    //        },
934    //    );
935
936    //    cancellable
937    //})
938    //}
939
940    fn copy_attributes<P: IsA<File>, Q: IsA<Cancellable>>(
941        &self,
942        destination: &P,
943        flags: FileCopyFlags,
944        cancellable: Option<&Q>,
945    ) -> Result<(), Error> {
946        unsafe {
947            let mut error = ptr::null_mut();
948            let _ = gio_sys::g_file_copy_attributes(
949                self.as_ref().to_glib_none().0,
950                destination.as_ref().to_glib_none().0,
951                flags.to_glib(),
952                cancellable.map(|p| p.as_ref()).to_glib_none().0,
953                &mut error,
954            );
955            if error.is_null() {
956                Ok(())
957            } else {
958                Err(from_glib_full(error))
959            }
960        }
961    }
962
963    fn create<P: IsA<Cancellable>>(
964        &self,
965        flags: FileCreateFlags,
966        cancellable: Option<&P>,
967    ) -> Result<FileOutputStream, Error> {
968        unsafe {
969            let mut error = ptr::null_mut();
970            let ret = gio_sys::g_file_create(
971                self.as_ref().to_glib_none().0,
972                flags.to_glib(),
973                cancellable.map(|p| p.as_ref()).to_glib_none().0,
974                &mut error,
975            );
976            if error.is_null() {
977                Ok(from_glib_full(ret))
978            } else {
979                Err(from_glib_full(error))
980            }
981        }
982    }
983
984    fn create_async<
985        P: IsA<Cancellable>,
986        Q: FnOnce(Result<FileOutputStream, Error>) + Send + 'static,
987    >(
988        &self,
989        flags: FileCreateFlags,
990        io_priority: glib::Priority,
991        cancellable: Option<&P>,
992        callback: Q,
993    ) {
994        let user_data: Box<Q> = Box::new(callback);
995        unsafe extern "C" fn create_async_trampoline<
996            Q: FnOnce(Result<FileOutputStream, Error>) + Send + 'static,
997        >(
998            _source_object: *mut gobject_sys::GObject,
999            res: *mut gio_sys::GAsyncResult,
1000            user_data: glib_sys::gpointer,
1001        ) {
1002            let mut error = ptr::null_mut();
1003            let ret = gio_sys::g_file_create_finish(_source_object as *mut _, res, &mut error);
1004            let result = if error.is_null() {
1005                Ok(from_glib_full(ret))
1006            } else {
1007                Err(from_glib_full(error))
1008            };
1009            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
1010            callback(result);
1011        }
1012        let callback = create_async_trampoline::<Q>;
1013        unsafe {
1014            gio_sys::g_file_create_async(
1015                self.as_ref().to_glib_none().0,
1016                flags.to_glib(),
1017                io_priority.to_glib(),
1018                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1019                Some(callback),
1020                Box::into_raw(user_data) as *mut _,
1021            );
1022        }
1023    }
1024
1025    #[cfg(feature = "futures")]
1026    fn create_async_future(
1027        &self,
1028        flags: FileCreateFlags,
1029        io_priority: glib::Priority,
1030    ) -> Box_<dyn future::Future<Output = Result<FileOutputStream, Error>> + std::marker::Unpin>
1031    {
1032        use fragile::Fragile;
1033        use GioFuture;
1034
1035        GioFuture::new(self, move |obj, send| {
1036            let cancellable = Cancellable::new();
1037            let send = Fragile::new(send);
1038            obj.create_async(flags, io_priority, Some(&cancellable), move |res| {
1039                let _ = send.into_inner().send(res);
1040            });
1041
1042            cancellable
1043        })
1044    }
1045
1046    fn create_readwrite<P: IsA<Cancellable>>(
1047        &self,
1048        flags: FileCreateFlags,
1049        cancellable: Option<&P>,
1050    ) -> Result<FileIOStream, Error> {
1051        unsafe {
1052            let mut error = ptr::null_mut();
1053            let ret = gio_sys::g_file_create_readwrite(
1054                self.as_ref().to_glib_none().0,
1055                flags.to_glib(),
1056                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1057                &mut error,
1058            );
1059            if error.is_null() {
1060                Ok(from_glib_full(ret))
1061            } else {
1062                Err(from_glib_full(error))
1063            }
1064        }
1065    }
1066
1067    fn create_readwrite_async<
1068        P: IsA<Cancellable>,
1069        Q: FnOnce(Result<FileIOStream, Error>) + Send + 'static,
1070    >(
1071        &self,
1072        flags: FileCreateFlags,
1073        io_priority: glib::Priority,
1074        cancellable: Option<&P>,
1075        callback: Q,
1076    ) {
1077        let user_data: Box<Q> = Box::new(callback);
1078        unsafe extern "C" fn create_readwrite_async_trampoline<
1079            Q: FnOnce(Result<FileIOStream, Error>) + Send + 'static,
1080        >(
1081            _source_object: *mut gobject_sys::GObject,
1082            res: *mut gio_sys::GAsyncResult,
1083            user_data: glib_sys::gpointer,
1084        ) {
1085            let mut error = ptr::null_mut();
1086            let ret =
1087                gio_sys::g_file_create_readwrite_finish(_source_object as *mut _, res, &mut error);
1088            let result = if error.is_null() {
1089                Ok(from_glib_full(ret))
1090            } else {
1091                Err(from_glib_full(error))
1092            };
1093            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
1094            callback(result);
1095        }
1096        let callback = create_readwrite_async_trampoline::<Q>;
1097        unsafe {
1098            gio_sys::g_file_create_readwrite_async(
1099                self.as_ref().to_glib_none().0,
1100                flags.to_glib(),
1101                io_priority.to_glib(),
1102                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1103                Some(callback),
1104                Box::into_raw(user_data) as *mut _,
1105            );
1106        }
1107    }
1108
1109    #[cfg(feature = "futures")]
1110    fn create_readwrite_async_future(
1111        &self,
1112        flags: FileCreateFlags,
1113        io_priority: glib::Priority,
1114    ) -> Box_<dyn future::Future<Output = Result<FileIOStream, Error>> + std::marker::Unpin> {
1115        use fragile::Fragile;
1116        use GioFuture;
1117
1118        GioFuture::new(self, move |obj, send| {
1119            let cancellable = Cancellable::new();
1120            let send = Fragile::new(send);
1121            obj.create_readwrite_async(flags, io_priority, Some(&cancellable), move |res| {
1122                let _ = send.into_inner().send(res);
1123            });
1124
1125            cancellable
1126        })
1127    }
1128
1129    fn delete<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), Error> {
1130        unsafe {
1131            let mut error = ptr::null_mut();
1132            let _ = gio_sys::g_file_delete(
1133                self.as_ref().to_glib_none().0,
1134                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1135                &mut error,
1136            );
1137            if error.is_null() {
1138                Ok(())
1139            } else {
1140                Err(from_glib_full(error))
1141            }
1142        }
1143    }
1144
1145    fn delete_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
1146        &self,
1147        io_priority: glib::Priority,
1148        cancellable: Option<&P>,
1149        callback: Q,
1150    ) {
1151        let user_data: Box<Q> = Box::new(callback);
1152        unsafe extern "C" fn delete_async_trampoline<
1153            Q: FnOnce(Result<(), Error>) + Send + 'static,
1154        >(
1155            _source_object: *mut gobject_sys::GObject,
1156            res: *mut gio_sys::GAsyncResult,
1157            user_data: glib_sys::gpointer,
1158        ) {
1159            let mut error = ptr::null_mut();
1160            let _ = gio_sys::g_file_delete_finish(_source_object as *mut _, res, &mut error);
1161            let result = if error.is_null() {
1162                Ok(())
1163            } else {
1164                Err(from_glib_full(error))
1165            };
1166            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
1167            callback(result);
1168        }
1169        let callback = delete_async_trampoline::<Q>;
1170        unsafe {
1171            gio_sys::g_file_delete_async(
1172                self.as_ref().to_glib_none().0,
1173                io_priority.to_glib(),
1174                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1175                Some(callback),
1176                Box::into_raw(user_data) as *mut _,
1177            );
1178        }
1179    }
1180
1181    #[cfg(feature = "futures")]
1182    fn delete_async_future(
1183        &self,
1184        io_priority: glib::Priority,
1185    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
1186        use fragile::Fragile;
1187        use GioFuture;
1188
1189        GioFuture::new(self, move |obj, send| {
1190            let cancellable = Cancellable::new();
1191            let send = Fragile::new(send);
1192            obj.delete_async(io_priority, Some(&cancellable), move |res| {
1193                let _ = send.into_inner().send(res);
1194            });
1195
1196            cancellable
1197        })
1198    }
1199
1200    fn dup(&self) -> Option<File> {
1201        unsafe { from_glib_full(gio_sys::g_file_dup(self.as_ref().to_glib_none().0)) }
1202    }
1203
1204    fn eject_mountable_with_operation<
1205        P: IsA<MountOperation>,
1206        Q: IsA<Cancellable>,
1207        R: FnOnce(Result<(), Error>) + Send + 'static,
1208    >(
1209        &self,
1210        flags: MountUnmountFlags,
1211        mount_operation: Option<&P>,
1212        cancellable: Option<&Q>,
1213        callback: R,
1214    ) {
1215        let user_data: Box<R> = Box::new(callback);
1216        unsafe extern "C" fn eject_mountable_with_operation_trampoline<
1217            R: FnOnce(Result<(), Error>) + Send + 'static,
1218        >(
1219            _source_object: *mut gobject_sys::GObject,
1220            res: *mut gio_sys::GAsyncResult,
1221            user_data: glib_sys::gpointer,
1222        ) {
1223            let mut error = ptr::null_mut();
1224            let _ = gio_sys::g_file_eject_mountable_with_operation_finish(
1225                _source_object as *mut _,
1226                res,
1227                &mut error,
1228            );
1229            let result = if error.is_null() {
1230                Ok(())
1231            } else {
1232                Err(from_glib_full(error))
1233            };
1234            let callback: Box<R> = Box::from_raw(user_data as *mut _);
1235            callback(result);
1236        }
1237        let callback = eject_mountable_with_operation_trampoline::<R>;
1238        unsafe {
1239            gio_sys::g_file_eject_mountable_with_operation(
1240                self.as_ref().to_glib_none().0,
1241                flags.to_glib(),
1242                mount_operation.map(|p| p.as_ref()).to_glib_none().0,
1243                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1244                Some(callback),
1245                Box::into_raw(user_data) as *mut _,
1246            );
1247        }
1248    }
1249
1250    #[cfg(feature = "futures")]
1251    fn eject_mountable_with_operation_future<P: IsA<MountOperation> + Clone + 'static>(
1252        &self,
1253        flags: MountUnmountFlags,
1254        mount_operation: Option<&P>,
1255    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
1256        use fragile::Fragile;
1257        use GioFuture;
1258
1259        let mount_operation = mount_operation.map(ToOwned::to_owned);
1260        GioFuture::new(self, move |obj, send| {
1261            let cancellable = Cancellable::new();
1262            let send = Fragile::new(send);
1263            obj.eject_mountable_with_operation(
1264                flags,
1265                mount_operation.as_ref().map(::std::borrow::Borrow::borrow),
1266                Some(&cancellable),
1267                move |res| {
1268                    let _ = send.into_inner().send(res);
1269                },
1270            );
1271
1272            cancellable
1273        })
1274    }
1275
1276    //fn enumerate_children<P: IsA<Cancellable>>(&self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>) -> Result</*Ignored*/FileEnumerator, Error> {
1277    //    unsafe { TODO: call gio_sys:g_file_enumerate_children() }
1278    //}
1279
1280    fn equal<P: IsA<File>>(&self, file2: &P) -> bool {
1281        unsafe {
1282            from_glib(gio_sys::g_file_equal(
1283                self.as_ref().to_glib_none().0,
1284                file2.as_ref().to_glib_none().0,
1285            ))
1286        }
1287    }
1288
1289    fn find_enclosing_mount<P: IsA<Cancellable>>(
1290        &self,
1291        cancellable: Option<&P>,
1292    ) -> Result<Mount, Error> {
1293        unsafe {
1294            let mut error = ptr::null_mut();
1295            let ret = gio_sys::g_file_find_enclosing_mount(
1296                self.as_ref().to_glib_none().0,
1297                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1298                &mut error,
1299            );
1300            if error.is_null() {
1301                Ok(from_glib_full(ret))
1302            } else {
1303                Err(from_glib_full(error))
1304            }
1305        }
1306    }
1307
1308    fn get_basename(&self) -> Option<std::path::PathBuf> {
1309        unsafe { from_glib_full(gio_sys::g_file_get_basename(self.as_ref().to_glib_none().0)) }
1310    }
1311
1312    fn get_child<P: AsRef<std::path::Path>>(&self, name: P) -> Option<File> {
1313        unsafe {
1314            from_glib_full(gio_sys::g_file_get_child(
1315                self.as_ref().to_glib_none().0,
1316                name.as_ref().to_glib_none().0,
1317            ))
1318        }
1319    }
1320
1321    fn get_child_for_display_name(&self, display_name: &str) -> Result<File, Error> {
1322        unsafe {
1323            let mut error = ptr::null_mut();
1324            let ret = gio_sys::g_file_get_child_for_display_name(
1325                self.as_ref().to_glib_none().0,
1326                display_name.to_glib_none().0,
1327                &mut error,
1328            );
1329            if error.is_null() {
1330                Ok(from_glib_full(ret))
1331            } else {
1332                Err(from_glib_full(error))
1333            }
1334        }
1335    }
1336
1337    fn get_parent(&self) -> Option<File> {
1338        unsafe { from_glib_full(gio_sys::g_file_get_parent(self.as_ref().to_glib_none().0)) }
1339    }
1340
1341    fn get_parse_name(&self) -> Option<GString> {
1342        unsafe {
1343            from_glib_full(gio_sys::g_file_get_parse_name(
1344                self.as_ref().to_glib_none().0,
1345            ))
1346        }
1347    }
1348
1349    fn get_path(&self) -> Option<std::path::PathBuf> {
1350        unsafe { from_glib_full(gio_sys::g_file_get_path(self.as_ref().to_glib_none().0)) }
1351    }
1352
1353    fn get_relative_path<P: IsA<File>>(&self, descendant: &P) -> Option<std::path::PathBuf> {
1354        unsafe {
1355            from_glib_full(gio_sys::g_file_get_relative_path(
1356                self.as_ref().to_glib_none().0,
1357                descendant.as_ref().to_glib_none().0,
1358            ))
1359        }
1360    }
1361
1362    fn get_uri(&self) -> GString {
1363        unsafe { from_glib_full(gio_sys::g_file_get_uri(self.as_ref().to_glib_none().0)) }
1364    }
1365
1366    fn get_uri_scheme(&self) -> GString {
1367        unsafe {
1368            from_glib_full(gio_sys::g_file_get_uri_scheme(
1369                self.as_ref().to_glib_none().0,
1370            ))
1371        }
1372    }
1373
1374    fn has_parent<P: IsA<File>>(&self, parent: Option<&P>) -> bool {
1375        unsafe {
1376            from_glib(gio_sys::g_file_has_parent(
1377                self.as_ref().to_glib_none().0,
1378                parent.map(|p| p.as_ref()).to_glib_none().0,
1379            ))
1380        }
1381    }
1382
1383    fn has_prefix<P: IsA<File>>(&self, prefix: &P) -> bool {
1384        unsafe {
1385            from_glib(gio_sys::g_file_has_prefix(
1386                self.as_ref().to_glib_none().0,
1387                prefix.as_ref().to_glib_none().0,
1388            ))
1389        }
1390    }
1391
1392    fn has_uri_scheme(&self, uri_scheme: &str) -> bool {
1393        unsafe {
1394            from_glib(gio_sys::g_file_has_uri_scheme(
1395                self.as_ref().to_glib_none().0,
1396                uri_scheme.to_glib_none().0,
1397            ))
1398        }
1399    }
1400
1401    fn is_native(&self) -> bool {
1402        unsafe { from_glib(gio_sys::g_file_is_native(self.as_ref().to_glib_none().0)) }
1403    }
1404
1405    #[cfg(any(feature = "v2_56", feature = "dox"))]
1406    fn load_bytes<P: IsA<Cancellable>>(
1407        &self,
1408        cancellable: Option<&P>,
1409    ) -> Result<(glib::Bytes, Option<GString>), Error> {
1410        unsafe {
1411            let mut etag_out = ptr::null_mut();
1412            let mut error = ptr::null_mut();
1413            let ret = gio_sys::g_file_load_bytes(
1414                self.as_ref().to_glib_none().0,
1415                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1416                &mut etag_out,
1417                &mut error,
1418            );
1419            if error.is_null() {
1420                Ok((from_glib_full(ret), from_glib_full(etag_out)))
1421            } else {
1422                Err(from_glib_full(error))
1423            }
1424        }
1425    }
1426
1427    #[cfg(any(feature = "v2_56", feature = "dox"))]
1428    fn load_bytes_async<
1429        P: IsA<Cancellable>,
1430        Q: FnOnce(Result<(glib::Bytes, GString), Error>) + Send + 'static,
1431    >(
1432        &self,
1433        cancellable: Option<&P>,
1434        callback: Q,
1435    ) {
1436        let user_data: Box<Q> = Box::new(callback);
1437        unsafe extern "C" fn load_bytes_async_trampoline<
1438            Q: FnOnce(Result<(glib::Bytes, GString), Error>) + Send + 'static,
1439        >(
1440            _source_object: *mut gobject_sys::GObject,
1441            res: *mut gio_sys::GAsyncResult,
1442            user_data: glib_sys::gpointer,
1443        ) {
1444            let mut error = ptr::null_mut();
1445            let mut etag_out = ptr::null_mut();
1446            let ret = gio_sys::g_file_load_bytes_finish(
1447                _source_object as *mut _,
1448                res,
1449                &mut etag_out,
1450                &mut error,
1451            );
1452            let result = if error.is_null() {
1453                Ok((from_glib_full(ret), from_glib_full(etag_out)))
1454            } else {
1455                Err(from_glib_full(error))
1456            };
1457            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
1458            callback(result);
1459        }
1460        let callback = load_bytes_async_trampoline::<Q>;
1461        unsafe {
1462            gio_sys::g_file_load_bytes_async(
1463                self.as_ref().to_glib_none().0,
1464                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1465                Some(callback),
1466                Box::into_raw(user_data) as *mut _,
1467            );
1468        }
1469    }
1470
1471    #[cfg(feature = "futures")]
1472    #[cfg(any(feature = "v2_56", feature = "dox"))]
1473    fn load_bytes_async_future(
1474        &self,
1475    ) -> Box_<dyn future::Future<Output = Result<(glib::Bytes, GString), Error>> + std::marker::Unpin>
1476    {
1477        use fragile::Fragile;
1478        use GioFuture;
1479
1480        GioFuture::new(self, move |obj, send| {
1481            let cancellable = Cancellable::new();
1482            let send = Fragile::new(send);
1483            obj.load_bytes_async(Some(&cancellable), move |res| {
1484                let _ = send.into_inner().send(res);
1485            });
1486
1487            cancellable
1488        })
1489    }
1490
1491    fn load_contents<P: IsA<Cancellable>>(
1492        &self,
1493        cancellable: Option<&P>,
1494    ) -> Result<(Vec<u8>, GString), Error> {
1495        unsafe {
1496            let mut contents = ptr::null_mut();
1497            let mut length = mem::uninitialized();
1498            let mut etag_out = ptr::null_mut();
1499            let mut error = ptr::null_mut();
1500            let _ = gio_sys::g_file_load_contents(
1501                self.as_ref().to_glib_none().0,
1502                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1503                &mut contents,
1504                &mut length,
1505                &mut etag_out,
1506                &mut error,
1507            );
1508            if error.is_null() {
1509                Ok((
1510                    FromGlibContainer::from_glib_full_num(contents, length as usize),
1511                    from_glib_full(etag_out),
1512                ))
1513            } else {
1514                Err(from_glib_full(error))
1515            }
1516        }
1517    }
1518
1519    fn load_contents_async<
1520        P: IsA<Cancellable>,
1521        Q: FnOnce(Result<(Vec<u8>, GString), Error>) + Send + 'static,
1522    >(
1523        &self,
1524        cancellable: Option<&P>,
1525        callback: Q,
1526    ) {
1527        let user_data: Box<Q> = Box::new(callback);
1528        unsafe extern "C" fn load_contents_async_trampoline<
1529            Q: FnOnce(Result<(Vec<u8>, GString), Error>) + Send + 'static,
1530        >(
1531            _source_object: *mut gobject_sys::GObject,
1532            res: *mut gio_sys::GAsyncResult,
1533            user_data: glib_sys::gpointer,
1534        ) {
1535            let mut error = ptr::null_mut();
1536            let mut contents = ptr::null_mut();
1537            let mut length = mem::uninitialized();
1538            let mut etag_out = ptr::null_mut();
1539            let _ = gio_sys::g_file_load_contents_finish(
1540                _source_object as *mut _,
1541                res,
1542                &mut contents,
1543                &mut length,
1544                &mut etag_out,
1545                &mut error,
1546            );
1547            let result = if error.is_null() {
1548                Ok((
1549                    FromGlibContainer::from_glib_full_num(contents, length as usize),
1550                    from_glib_full(etag_out),
1551                ))
1552            } else {
1553                Err(from_glib_full(error))
1554            };
1555            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
1556            callback(result);
1557        }
1558        let callback = load_contents_async_trampoline::<Q>;
1559        unsafe {
1560            gio_sys::g_file_load_contents_async(
1561                self.as_ref().to_glib_none().0,
1562                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1563                Some(callback),
1564                Box::into_raw(user_data) as *mut _,
1565            );
1566        }
1567    }
1568
1569    #[cfg(feature = "futures")]
1570    fn load_contents_async_future(
1571        &self,
1572    ) -> Box_<dyn future::Future<Output = Result<(Vec<u8>, GString), Error>> + std::marker::Unpin>
1573    {
1574        use fragile::Fragile;
1575        use GioFuture;
1576
1577        GioFuture::new(self, move |obj, send| {
1578            let cancellable = Cancellable::new();
1579            let send = Fragile::new(send);
1580            obj.load_contents_async(Some(&cancellable), move |res| {
1581                let _ = send.into_inner().send(res);
1582            });
1583
1584            cancellable
1585        })
1586    }
1587
1588    //fn load_partial_contents_async<P: IsA<Cancellable>, Q: FnOnce(Result<(Vec<u8>, GString), Error>) + Send + 'static, R: FnOnce(Result<(Vec<u8>, GString), Error>) + Send + 'static>(&self, cancellable: Option<&P>, read_more_callback: Q, callback: R) {
1589    //    unsafe { TODO: call gio_sys:g_file_load_partial_contents_async() }
1590    //}
1591
1592    //#[cfg(feature = "futures")]
1593    //fn load_partial_contents_async_future<Q: FnOnce(Result<(Vec<u8>, GString), Error>) + Send + 'static>(&self, read_more_callback: Q) -> Box_<dyn future::Future<Output = Result<(Vec<u8>, GString), Error>> + std::marker::Unpin> {
1594    //use GioFuture;
1595    //use fragile::Fragile;
1596
1597    //GioFuture::new(self, move |obj, send| {
1598    //    let cancellable = Cancellable::new();
1599    //    let send = Fragile::new(send);
1600    //    obj.load_partial_contents_async(
1601    //        Some(&cancellable),
1602    //        read_more_callback,
1603    //        move |res| {
1604    //            let _ = send.into_inner().send(res);
1605    //        },
1606    //    );
1607
1608    //    cancellable
1609    //})
1610    //}
1611
1612    fn make_directory<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), Error> {
1613        unsafe {
1614            let mut error = ptr::null_mut();
1615            let _ = gio_sys::g_file_make_directory(
1616                self.as_ref().to_glib_none().0,
1617                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1618                &mut error,
1619            );
1620            if error.is_null() {
1621                Ok(())
1622            } else {
1623                Err(from_glib_full(error))
1624            }
1625        }
1626    }
1627
1628    fn make_directory_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
1629        &self,
1630        io_priority: glib::Priority,
1631        cancellable: Option<&P>,
1632        callback: Q,
1633    ) {
1634        let user_data: Box<Q> = Box::new(callback);
1635        unsafe extern "C" fn make_directory_async_trampoline<
1636            Q: FnOnce(Result<(), Error>) + Send + 'static,
1637        >(
1638            _source_object: *mut gobject_sys::GObject,
1639            res: *mut gio_sys::GAsyncResult,
1640            user_data: glib_sys::gpointer,
1641        ) {
1642            let mut error = ptr::null_mut();
1643            let _ =
1644                gio_sys::g_file_make_directory_finish(_source_object as *mut _, res, &mut error);
1645            let result = if error.is_null() {
1646                Ok(())
1647            } else {
1648                Err(from_glib_full(error))
1649            };
1650            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
1651            callback(result);
1652        }
1653        let callback = make_directory_async_trampoline::<Q>;
1654        unsafe {
1655            gio_sys::g_file_make_directory_async(
1656                self.as_ref().to_glib_none().0,
1657                io_priority.to_glib(),
1658                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1659                Some(callback),
1660                Box::into_raw(user_data) as *mut _,
1661            );
1662        }
1663    }
1664
1665    #[cfg(feature = "futures")]
1666    fn make_directory_async_future(
1667        &self,
1668        io_priority: glib::Priority,
1669    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
1670        use fragile::Fragile;
1671        use GioFuture;
1672
1673        GioFuture::new(self, move |obj, send| {
1674            let cancellable = Cancellable::new();
1675            let send = Fragile::new(send);
1676            obj.make_directory_async(io_priority, Some(&cancellable), move |res| {
1677                let _ = send.into_inner().send(res);
1678            });
1679
1680            cancellable
1681        })
1682    }
1683
1684    fn make_directory_with_parents<P: IsA<Cancellable>>(
1685        &self,
1686        cancellable: Option<&P>,
1687    ) -> Result<(), Error> {
1688        unsafe {
1689            let mut error = ptr::null_mut();
1690            let _ = gio_sys::g_file_make_directory_with_parents(
1691                self.as_ref().to_glib_none().0,
1692                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1693                &mut error,
1694            );
1695            if error.is_null() {
1696                Ok(())
1697            } else {
1698                Err(from_glib_full(error))
1699            }
1700        }
1701    }
1702
1703    fn make_symbolic_link<P: AsRef<std::path::Path>, Q: IsA<Cancellable>>(
1704        &self,
1705        symlink_value: P,
1706        cancellable: Option<&Q>,
1707    ) -> Result<(), Error> {
1708        unsafe {
1709            let mut error = ptr::null_mut();
1710            let _ = gio_sys::g_file_make_symbolic_link(
1711                self.as_ref().to_glib_none().0,
1712                symlink_value.as_ref().to_glib_none().0,
1713                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1714                &mut error,
1715            );
1716            if error.is_null() {
1717                Ok(())
1718            } else {
1719                Err(from_glib_full(error))
1720            }
1721        }
1722    }
1723
1724    fn measure_disk_usage<P: IsA<Cancellable>>(
1725        &self,
1726        flags: FileMeasureFlags,
1727        cancellable: Option<&P>,
1728        progress_callback: Option<Box<dyn Fn(bool, u64, u64, u64) + 'static>>,
1729    ) -> Result<(u64, u64, u64), Error> {
1730        let progress_callback_data: Box_<Option<Box<dyn Fn(bool, u64, u64, u64) + 'static>>> =
1731            Box::new(progress_callback);
1732        unsafe extern "C" fn progress_callback_func<P: IsA<Cancellable>>(
1733            reporting: glib_sys::gboolean,
1734            current_size: u64,
1735            num_dirs: u64,
1736            num_files: u64,
1737            user_data: glib_sys::gpointer,
1738        ) {
1739            let reporting = from_glib(reporting);
1740            let callback: &Option<Box<dyn Fn(bool, u64, u64, u64) + 'static>> =
1741                &*(user_data as *mut _);
1742            if let Some(ref callback) = *callback {
1743                callback(reporting, current_size, num_dirs, num_files)
1744            } else {
1745                panic!("cannot get closure...")
1746            };
1747        }
1748        let progress_callback = if progress_callback_data.is_some() {
1749            Some(progress_callback_func::<P> as _)
1750        } else {
1751            None
1752        };
1753        let super_callback0: Box_<Option<Box<dyn Fn(bool, u64, u64, u64) + 'static>>> =
1754            progress_callback_data;
1755        unsafe {
1756            let mut disk_usage = mem::uninitialized();
1757            let mut num_dirs = mem::uninitialized();
1758            let mut num_files = mem::uninitialized();
1759            let mut error = ptr::null_mut();
1760            let _ = gio_sys::g_file_measure_disk_usage(
1761                self.as_ref().to_glib_none().0,
1762                flags.to_glib(),
1763                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1764                progress_callback,
1765                Box::into_raw(super_callback0) as *mut _,
1766                &mut disk_usage,
1767                &mut num_dirs,
1768                &mut num_files,
1769                &mut error,
1770            );
1771            if error.is_null() {
1772                Ok((disk_usage, num_dirs, num_files))
1773            } else {
1774                Err(from_glib_full(error))
1775            }
1776        }
1777    }
1778
1779    //fn measure_disk_usage_async<P: IsA<Cancellable>, Q: FnOnce(Result<(u64, u64, u64), Error>) + Send + 'static, R: FnOnce(Result<(u64, u64, u64), Error>) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, cancellable: Option<&P>, progress_callback: Q, callback: R) {
1780    //    unsafe { TODO: call gio_sys:g_file_measure_disk_usage_async() }
1781    //}
1782
1783    //#[cfg(feature = "futures")]
1784    //fn measure_disk_usage_async_future<Q: FnOnce(Result<(u64, u64, u64), Error>) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, progress_callback: Q) -> Box_<dyn future::Future<Output = Result<(u64, u64, u64), Error>> + std::marker::Unpin> {
1785    //use GioFuture;
1786    //use fragile::Fragile;
1787
1788    //let progress_callback = progress_callback.map(ToOwned::to_owned);
1789    //GioFuture::new(self, move |obj, send| {
1790    //    let cancellable = Cancellable::new();
1791    //    let send = Fragile::new(send);
1792    //    obj.measure_disk_usage_async(
1793    //        flags,
1794    //        io_priority,
1795    //        Some(&cancellable),
1796    //        progress_callback.as_ref().map(::std::borrow::Borrow::borrow),
1797    //        move |res| {
1798    //            let _ = send.into_inner().send(res);
1799    //        },
1800    //    );
1801
1802    //    cancellable
1803    //})
1804    //}
1805
1806    fn monitor<P: IsA<Cancellable>>(
1807        &self,
1808        flags: FileMonitorFlags,
1809        cancellable: Option<&P>,
1810    ) -> Result<FileMonitor, Error> {
1811        unsafe {
1812            let mut error = ptr::null_mut();
1813            let ret = gio_sys::g_file_monitor(
1814                self.as_ref().to_glib_none().0,
1815                flags.to_glib(),
1816                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1817                &mut error,
1818            );
1819            if error.is_null() {
1820                Ok(from_glib_full(ret))
1821            } else {
1822                Err(from_glib_full(error))
1823            }
1824        }
1825    }
1826
1827    fn monitor_directory<P: IsA<Cancellable>>(
1828        &self,
1829        flags: FileMonitorFlags,
1830        cancellable: Option<&P>,
1831    ) -> Result<FileMonitor, Error> {
1832        unsafe {
1833            let mut error = ptr::null_mut();
1834            let ret = gio_sys::g_file_monitor_directory(
1835                self.as_ref().to_glib_none().0,
1836                flags.to_glib(),
1837                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1838                &mut error,
1839            );
1840            if error.is_null() {
1841                Ok(from_glib_full(ret))
1842            } else {
1843                Err(from_glib_full(error))
1844            }
1845        }
1846    }
1847
1848    fn monitor_file<P: IsA<Cancellable>>(
1849        &self,
1850        flags: FileMonitorFlags,
1851        cancellable: Option<&P>,
1852    ) -> Result<FileMonitor, Error> {
1853        unsafe {
1854            let mut error = ptr::null_mut();
1855            let ret = gio_sys::g_file_monitor_file(
1856                self.as_ref().to_glib_none().0,
1857                flags.to_glib(),
1858                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1859                &mut error,
1860            );
1861            if error.is_null() {
1862                Ok(from_glib_full(ret))
1863            } else {
1864                Err(from_glib_full(error))
1865            }
1866        }
1867    }
1868
1869    fn mount_enclosing_volume<
1870        P: IsA<MountOperation>,
1871        Q: IsA<Cancellable>,
1872        R: FnOnce(Result<(), Error>) + Send + 'static,
1873    >(
1874        &self,
1875        flags: MountMountFlags,
1876        mount_operation: Option<&P>,
1877        cancellable: Option<&Q>,
1878        callback: R,
1879    ) {
1880        let user_data: Box<R> = Box::new(callback);
1881        unsafe extern "C" fn mount_enclosing_volume_trampoline<
1882            R: FnOnce(Result<(), Error>) + Send + 'static,
1883        >(
1884            _source_object: *mut gobject_sys::GObject,
1885            res: *mut gio_sys::GAsyncResult,
1886            user_data: glib_sys::gpointer,
1887        ) {
1888            let mut error = ptr::null_mut();
1889            let _ = gio_sys::g_file_mount_enclosing_volume_finish(
1890                _source_object as *mut _,
1891                res,
1892                &mut error,
1893            );
1894            let result = if error.is_null() {
1895                Ok(())
1896            } else {
1897                Err(from_glib_full(error))
1898            };
1899            let callback: Box<R> = Box::from_raw(user_data as *mut _);
1900            callback(result);
1901        }
1902        let callback = mount_enclosing_volume_trampoline::<R>;
1903        unsafe {
1904            gio_sys::g_file_mount_enclosing_volume(
1905                self.as_ref().to_glib_none().0,
1906                flags.to_glib(),
1907                mount_operation.map(|p| p.as_ref()).to_glib_none().0,
1908                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1909                Some(callback),
1910                Box::into_raw(user_data) as *mut _,
1911            );
1912        }
1913    }
1914
1915    #[cfg(feature = "futures")]
1916    fn mount_enclosing_volume_future<P: IsA<MountOperation> + Clone + 'static>(
1917        &self,
1918        flags: MountMountFlags,
1919        mount_operation: Option<&P>,
1920    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
1921        use fragile::Fragile;
1922        use GioFuture;
1923
1924        let mount_operation = mount_operation.map(ToOwned::to_owned);
1925        GioFuture::new(self, move |obj, send| {
1926            let cancellable = Cancellable::new();
1927            let send = Fragile::new(send);
1928            obj.mount_enclosing_volume(
1929                flags,
1930                mount_operation.as_ref().map(::std::borrow::Borrow::borrow),
1931                Some(&cancellable),
1932                move |res| {
1933                    let _ = send.into_inner().send(res);
1934                },
1935            );
1936
1937            cancellable
1938        })
1939    }
1940
1941    fn mount_mountable<
1942        P: IsA<MountOperation>,
1943        Q: IsA<Cancellable>,
1944        R: FnOnce(Result<File, Error>) + Send + 'static,
1945    >(
1946        &self,
1947        flags: MountMountFlags,
1948        mount_operation: Option<&P>,
1949        cancellable: Option<&Q>,
1950        callback: R,
1951    ) {
1952        let user_data: Box<R> = Box::new(callback);
1953        unsafe extern "C" fn mount_mountable_trampoline<
1954            R: FnOnce(Result<File, Error>) + Send + 'static,
1955        >(
1956            _source_object: *mut gobject_sys::GObject,
1957            res: *mut gio_sys::GAsyncResult,
1958            user_data: glib_sys::gpointer,
1959        ) {
1960            let mut error = ptr::null_mut();
1961            let ret =
1962                gio_sys::g_file_mount_mountable_finish(_source_object as *mut _, res, &mut error);
1963            let result = if error.is_null() {
1964                Ok(from_glib_full(ret))
1965            } else {
1966                Err(from_glib_full(error))
1967            };
1968            let callback: Box<R> = Box::from_raw(user_data as *mut _);
1969            callback(result);
1970        }
1971        let callback = mount_mountable_trampoline::<R>;
1972        unsafe {
1973            gio_sys::g_file_mount_mountable(
1974                self.as_ref().to_glib_none().0,
1975                flags.to_glib(),
1976                mount_operation.map(|p| p.as_ref()).to_glib_none().0,
1977                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1978                Some(callback),
1979                Box::into_raw(user_data) as *mut _,
1980            );
1981        }
1982    }
1983
1984    #[cfg(feature = "futures")]
1985    fn mount_mountable_future<P: IsA<MountOperation> + Clone + 'static>(
1986        &self,
1987        flags: MountMountFlags,
1988        mount_operation: Option<&P>,
1989    ) -> Box_<dyn future::Future<Output = Result<File, Error>> + std::marker::Unpin> {
1990        use fragile::Fragile;
1991        use GioFuture;
1992
1993        let mount_operation = mount_operation.map(ToOwned::to_owned);
1994        GioFuture::new(self, move |obj, send| {
1995            let cancellable = Cancellable::new();
1996            let send = Fragile::new(send);
1997            obj.mount_mountable(
1998                flags,
1999                mount_operation.as_ref().map(::std::borrow::Borrow::borrow),
2000                Some(&cancellable),
2001                move |res| {
2002                    let _ = send.into_inner().send(res);
2003                },
2004            );
2005
2006            cancellable
2007        })
2008    }
2009
2010    fn move_<P: IsA<File>, Q: IsA<Cancellable>>(
2011        &self,
2012        destination: &P,
2013        flags: FileCopyFlags,
2014        cancellable: Option<&Q>,
2015        progress_callback: Option<&mut dyn (FnMut(i64, i64))>,
2016    ) -> Result<(), Error> {
2017        let progress_callback_data: Option<&mut dyn (FnMut(i64, i64))> = progress_callback;
2018        unsafe extern "C" fn progress_callback_func<P: IsA<File>, Q: IsA<Cancellable>>(
2019            current_num_bytes: i64,
2020            total_num_bytes: i64,
2021            user_data: glib_sys::gpointer,
2022        ) {
2023            let callback: *mut Option<&mut dyn (FnMut(i64, i64))> =
2024                user_data as *const _ as usize as *mut Option<&mut dyn (FnMut(i64, i64))>;
2025            if let Some(ref mut callback) = *callback {
2026                callback(current_num_bytes, total_num_bytes)
2027            } else {
2028                panic!("cannot get closure...")
2029            };
2030        }
2031        let progress_callback = if progress_callback_data.is_some() {
2032            Some(progress_callback_func::<P, Q> as _)
2033        } else {
2034            None
2035        };
2036        let super_callback0: &Option<&mut dyn (FnMut(i64, i64))> = &progress_callback_data;
2037        unsafe {
2038            let mut error = ptr::null_mut();
2039            let _ = gio_sys::g_file_move(
2040                self.as_ref().to_glib_none().0,
2041                destination.as_ref().to_glib_none().0,
2042                flags.to_glib(),
2043                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2044                progress_callback,
2045                super_callback0 as *const _ as usize as *mut _,
2046                &mut error,
2047            );
2048            if error.is_null() {
2049                Ok(())
2050            } else {
2051                Err(from_glib_full(error))
2052            }
2053        }
2054    }
2055
2056    fn open_readwrite<P: IsA<Cancellable>>(
2057        &self,
2058        cancellable: Option<&P>,
2059    ) -> Result<FileIOStream, Error> {
2060        unsafe {
2061            let mut error = ptr::null_mut();
2062            let ret = gio_sys::g_file_open_readwrite(
2063                self.as_ref().to_glib_none().0,
2064                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2065                &mut error,
2066            );
2067            if error.is_null() {
2068                Ok(from_glib_full(ret))
2069            } else {
2070                Err(from_glib_full(error))
2071            }
2072        }
2073    }
2074
2075    fn open_readwrite_async<
2076        P: IsA<Cancellable>,
2077        Q: FnOnce(Result<FileIOStream, Error>) + Send + 'static,
2078    >(
2079        &self,
2080        io_priority: glib::Priority,
2081        cancellable: Option<&P>,
2082        callback: Q,
2083    ) {
2084        let user_data: Box<Q> = Box::new(callback);
2085        unsafe extern "C" fn open_readwrite_async_trampoline<
2086            Q: FnOnce(Result<FileIOStream, Error>) + Send + 'static,
2087        >(
2088            _source_object: *mut gobject_sys::GObject,
2089            res: *mut gio_sys::GAsyncResult,
2090            user_data: glib_sys::gpointer,
2091        ) {
2092            let mut error = ptr::null_mut();
2093            let ret =
2094                gio_sys::g_file_open_readwrite_finish(_source_object as *mut _, res, &mut error);
2095            let result = if error.is_null() {
2096                Ok(from_glib_full(ret))
2097            } else {
2098                Err(from_glib_full(error))
2099            };
2100            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
2101            callback(result);
2102        }
2103        let callback = open_readwrite_async_trampoline::<Q>;
2104        unsafe {
2105            gio_sys::g_file_open_readwrite_async(
2106                self.as_ref().to_glib_none().0,
2107                io_priority.to_glib(),
2108                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2109                Some(callback),
2110                Box::into_raw(user_data) as *mut _,
2111            );
2112        }
2113    }
2114
2115    #[cfg(feature = "futures")]
2116    fn open_readwrite_async_future(
2117        &self,
2118        io_priority: glib::Priority,
2119    ) -> Box_<dyn future::Future<Output = Result<FileIOStream, Error>> + std::marker::Unpin> {
2120        use fragile::Fragile;
2121        use GioFuture;
2122
2123        GioFuture::new(self, move |obj, send| {
2124            let cancellable = Cancellable::new();
2125            let send = Fragile::new(send);
2126            obj.open_readwrite_async(io_priority, Some(&cancellable), move |res| {
2127                let _ = send.into_inner().send(res);
2128            });
2129
2130            cancellable
2131        })
2132    }
2133
2134    #[cfg(any(feature = "v2_56", feature = "dox"))]
2135    fn peek_path(&self) -> Option<std::path::PathBuf> {
2136        unsafe { from_glib_none(gio_sys::g_file_peek_path(self.as_ref().to_glib_none().0)) }
2137    }
2138
2139    fn poll_mountable<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
2140        &self,
2141        cancellable: Option<&P>,
2142        callback: Q,
2143    ) {
2144        let user_data: Box<Q> = Box::new(callback);
2145        unsafe extern "C" fn poll_mountable_trampoline<
2146            Q: FnOnce(Result<(), Error>) + Send + 'static,
2147        >(
2148            _source_object: *mut gobject_sys::GObject,
2149            res: *mut gio_sys::GAsyncResult,
2150            user_data: glib_sys::gpointer,
2151        ) {
2152            let mut error = ptr::null_mut();
2153            let _ =
2154                gio_sys::g_file_poll_mountable_finish(_source_object as *mut _, res, &mut error);
2155            let result = if error.is_null() {
2156                Ok(())
2157            } else {
2158                Err(from_glib_full(error))
2159            };
2160            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
2161            callback(result);
2162        }
2163        let callback = poll_mountable_trampoline::<Q>;
2164        unsafe {
2165            gio_sys::g_file_poll_mountable(
2166                self.as_ref().to_glib_none().0,
2167                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2168                Some(callback),
2169                Box::into_raw(user_data) as *mut _,
2170            );
2171        }
2172    }
2173
2174    #[cfg(feature = "futures")]
2175    fn poll_mountable_future(
2176        &self,
2177    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
2178        use fragile::Fragile;
2179        use GioFuture;
2180
2181        GioFuture::new(self, move |obj, send| {
2182            let cancellable = Cancellable::new();
2183            let send = Fragile::new(send);
2184            obj.poll_mountable(Some(&cancellable), move |res| {
2185                let _ = send.into_inner().send(res);
2186            });
2187
2188            cancellable
2189        })
2190    }
2191
2192    fn query_default_handler<P: IsA<Cancellable>>(
2193        &self,
2194        cancellable: Option<&P>,
2195    ) -> Result<AppInfo, Error> {
2196        unsafe {
2197            let mut error = ptr::null_mut();
2198            let ret = gio_sys::g_file_query_default_handler(
2199                self.as_ref().to_glib_none().0,
2200                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2201                &mut error,
2202            );
2203            if error.is_null() {
2204                Ok(from_glib_full(ret))
2205            } else {
2206                Err(from_glib_full(error))
2207            }
2208        }
2209    }
2210
2211    fn query_exists<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> bool {
2212        unsafe {
2213            from_glib(gio_sys::g_file_query_exists(
2214                self.as_ref().to_glib_none().0,
2215                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2216            ))
2217        }
2218    }
2219
2220    fn query_file_type<P: IsA<Cancellable>>(
2221        &self,
2222        flags: FileQueryInfoFlags,
2223        cancellable: Option<&P>,
2224    ) -> FileType {
2225        unsafe {
2226            from_glib(gio_sys::g_file_query_file_type(
2227                self.as_ref().to_glib_none().0,
2228                flags.to_glib(),
2229                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2230            ))
2231        }
2232    }
2233
2234    fn query_filesystem_info<P: IsA<Cancellable>>(
2235        &self,
2236        attributes: &str,
2237        cancellable: Option<&P>,
2238    ) -> Result<FileInfo, Error> {
2239        unsafe {
2240            let mut error = ptr::null_mut();
2241            let ret = gio_sys::g_file_query_filesystem_info(
2242                self.as_ref().to_glib_none().0,
2243                attributes.to_glib_none().0,
2244                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2245                &mut error,
2246            );
2247            if error.is_null() {
2248                Ok(from_glib_full(ret))
2249            } else {
2250                Err(from_glib_full(error))
2251            }
2252        }
2253    }
2254
2255    fn query_filesystem_info_async<
2256        P: IsA<Cancellable>,
2257        Q: FnOnce(Result<FileInfo, Error>) + Send + 'static,
2258    >(
2259        &self,
2260        attributes: &str,
2261        io_priority: glib::Priority,
2262        cancellable: Option<&P>,
2263        callback: Q,
2264    ) {
2265        let user_data: Box<Q> = Box::new(callback);
2266        unsafe extern "C" fn query_filesystem_info_async_trampoline<
2267            Q: FnOnce(Result<FileInfo, Error>) + Send + 'static,
2268        >(
2269            _source_object: *mut gobject_sys::GObject,
2270            res: *mut gio_sys::GAsyncResult,
2271            user_data: glib_sys::gpointer,
2272        ) {
2273            let mut error = ptr::null_mut();
2274            let ret = gio_sys::g_file_query_filesystem_info_finish(
2275                _source_object as *mut _,
2276                res,
2277                &mut error,
2278            );
2279            let result = if error.is_null() {
2280                Ok(from_glib_full(ret))
2281            } else {
2282                Err(from_glib_full(error))
2283            };
2284            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
2285            callback(result);
2286        }
2287        let callback = query_filesystem_info_async_trampoline::<Q>;
2288        unsafe {
2289            gio_sys::g_file_query_filesystem_info_async(
2290                self.as_ref().to_glib_none().0,
2291                attributes.to_glib_none().0,
2292                io_priority.to_glib(),
2293                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2294                Some(callback),
2295                Box::into_raw(user_data) as *mut _,
2296            );
2297        }
2298    }
2299
2300    #[cfg(feature = "futures")]
2301    fn query_filesystem_info_async_future(
2302        &self,
2303        attributes: &str,
2304        io_priority: glib::Priority,
2305    ) -> Box_<dyn future::Future<Output = Result<FileInfo, Error>> + std::marker::Unpin> {
2306        use fragile::Fragile;
2307        use GioFuture;
2308
2309        let attributes = String::from(attributes);
2310        GioFuture::new(self, move |obj, send| {
2311            let cancellable = Cancellable::new();
2312            let send = Fragile::new(send);
2313            obj.query_filesystem_info_async(
2314                &attributes,
2315                io_priority,
2316                Some(&cancellable),
2317                move |res| {
2318                    let _ = send.into_inner().send(res);
2319                },
2320            );
2321
2322            cancellable
2323        })
2324    }
2325
2326    fn query_info<P: IsA<Cancellable>>(
2327        &self,
2328        attributes: &str,
2329        flags: FileQueryInfoFlags,
2330        cancellable: Option<&P>,
2331    ) -> Result<FileInfo, Error> {
2332        unsafe {
2333            let mut error = ptr::null_mut();
2334            let ret = gio_sys::g_file_query_info(
2335                self.as_ref().to_glib_none().0,
2336                attributes.to_glib_none().0,
2337                flags.to_glib(),
2338                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2339                &mut error,
2340            );
2341            if error.is_null() {
2342                Ok(from_glib_full(ret))
2343            } else {
2344                Err(from_glib_full(error))
2345            }
2346        }
2347    }
2348
2349    fn query_info_async<
2350        P: IsA<Cancellable>,
2351        Q: FnOnce(Result<FileInfo, Error>) + Send + 'static,
2352    >(
2353        &self,
2354        attributes: &str,
2355        flags: FileQueryInfoFlags,
2356        io_priority: glib::Priority,
2357        cancellable: Option<&P>,
2358        callback: Q,
2359    ) {
2360        let user_data: Box<Q> = Box::new(callback);
2361        unsafe extern "C" fn query_info_async_trampoline<
2362            Q: FnOnce(Result<FileInfo, Error>) + Send + 'static,
2363        >(
2364            _source_object: *mut gobject_sys::GObject,
2365            res: *mut gio_sys::GAsyncResult,
2366            user_data: glib_sys::gpointer,
2367        ) {
2368            let mut error = ptr::null_mut();
2369            let ret = gio_sys::g_file_query_info_finish(_source_object as *mut _, res, &mut error);
2370            let result = if error.is_null() {
2371                Ok(from_glib_full(ret))
2372            } else {
2373                Err(from_glib_full(error))
2374            };
2375            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
2376            callback(result);
2377        }
2378        let callback = query_info_async_trampoline::<Q>;
2379        unsafe {
2380            gio_sys::g_file_query_info_async(
2381                self.as_ref().to_glib_none().0,
2382                attributes.to_glib_none().0,
2383                flags.to_glib(),
2384                io_priority.to_glib(),
2385                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2386                Some(callback),
2387                Box::into_raw(user_data) as *mut _,
2388            );
2389        }
2390    }
2391
2392    #[cfg(feature = "futures")]
2393    fn query_info_async_future(
2394        &self,
2395        attributes: &str,
2396        flags: FileQueryInfoFlags,
2397        io_priority: glib::Priority,
2398    ) -> Box_<dyn future::Future<Output = Result<FileInfo, Error>> + std::marker::Unpin> {
2399        use fragile::Fragile;
2400        use GioFuture;
2401
2402        let attributes = String::from(attributes);
2403        GioFuture::new(self, move |obj, send| {
2404            let cancellable = Cancellable::new();
2405            let send = Fragile::new(send);
2406            obj.query_info_async(
2407                &attributes,
2408                flags,
2409                io_priority,
2410                Some(&cancellable),
2411                move |res| {
2412                    let _ = send.into_inner().send(res);
2413                },
2414            );
2415
2416            cancellable
2417        })
2418    }
2419
2420    //fn query_settable_attributes<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result</*Ignored*/FileAttributeInfoList, Error> {
2421    //    unsafe { TODO: call gio_sys:g_file_query_settable_attributes() }
2422    //}
2423
2424    //fn query_writable_namespaces<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result</*Ignored*/FileAttributeInfoList, Error> {
2425    //    unsafe { TODO: call gio_sys:g_file_query_writable_namespaces() }
2426    //}
2427
2428    fn read<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<FileInputStream, Error> {
2429        unsafe {
2430            let mut error = ptr::null_mut();
2431            let ret = gio_sys::g_file_read(
2432                self.as_ref().to_glib_none().0,
2433                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2434                &mut error,
2435            );
2436            if error.is_null() {
2437                Ok(from_glib_full(ret))
2438            } else {
2439                Err(from_glib_full(error))
2440            }
2441        }
2442    }
2443
2444    fn read_async<
2445        P: IsA<Cancellable>,
2446        Q: FnOnce(Result<FileInputStream, Error>) + Send + 'static,
2447    >(
2448        &self,
2449        io_priority: glib::Priority,
2450        cancellable: Option<&P>,
2451        callback: Q,
2452    ) {
2453        let user_data: Box<Q> = Box::new(callback);
2454        unsafe extern "C" fn read_async_trampoline<
2455            Q: FnOnce(Result<FileInputStream, Error>) + Send + 'static,
2456        >(
2457            _source_object: *mut gobject_sys::GObject,
2458            res: *mut gio_sys::GAsyncResult,
2459            user_data: glib_sys::gpointer,
2460        ) {
2461            let mut error = ptr::null_mut();
2462            let ret = gio_sys::g_file_read_finish(_source_object as *mut _, res, &mut error);
2463            let result = if error.is_null() {
2464                Ok(from_glib_full(ret))
2465            } else {
2466                Err(from_glib_full(error))
2467            };
2468            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
2469            callback(result);
2470        }
2471        let callback = read_async_trampoline::<Q>;
2472        unsafe {
2473            gio_sys::g_file_read_async(
2474                self.as_ref().to_glib_none().0,
2475                io_priority.to_glib(),
2476                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2477                Some(callback),
2478                Box::into_raw(user_data) as *mut _,
2479            );
2480        }
2481    }
2482
2483    #[cfg(feature = "futures")]
2484    fn read_async_future(
2485        &self,
2486        io_priority: glib::Priority,
2487    ) -> Box_<dyn future::Future<Output = Result<FileInputStream, Error>> + std::marker::Unpin>
2488    {
2489        use fragile::Fragile;
2490        use GioFuture;
2491
2492        GioFuture::new(self, move |obj, send| {
2493            let cancellable = Cancellable::new();
2494            let send = Fragile::new(send);
2495            obj.read_async(io_priority, Some(&cancellable), move |res| {
2496                let _ = send.into_inner().send(res);
2497            });
2498
2499            cancellable
2500        })
2501    }
2502
2503    fn replace<P: IsA<Cancellable>>(
2504        &self,
2505        etag: Option<&str>,
2506        make_backup: bool,
2507        flags: FileCreateFlags,
2508        cancellable: Option<&P>,
2509    ) -> Result<FileOutputStream, Error> {
2510        unsafe {
2511            let mut error = ptr::null_mut();
2512            let ret = gio_sys::g_file_replace(
2513                self.as_ref().to_glib_none().0,
2514                etag.to_glib_none().0,
2515                make_backup.to_glib(),
2516                flags.to_glib(),
2517                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2518                &mut error,
2519            );
2520            if error.is_null() {
2521                Ok(from_glib_full(ret))
2522            } else {
2523                Err(from_glib_full(error))
2524            }
2525        }
2526    }
2527
2528    fn replace_async<
2529        P: IsA<Cancellable>,
2530        Q: FnOnce(Result<FileOutputStream, Error>) + Send + 'static,
2531    >(
2532        &self,
2533        etag: Option<&str>,
2534        make_backup: bool,
2535        flags: FileCreateFlags,
2536        io_priority: glib::Priority,
2537        cancellable: Option<&P>,
2538        callback: Q,
2539    ) {
2540        let user_data: Box<Q> = Box::new(callback);
2541        unsafe extern "C" fn replace_async_trampoline<
2542            Q: FnOnce(Result<FileOutputStream, Error>) + Send + 'static,
2543        >(
2544            _source_object: *mut gobject_sys::GObject,
2545            res: *mut gio_sys::GAsyncResult,
2546            user_data: glib_sys::gpointer,
2547        ) {
2548            let mut error = ptr::null_mut();
2549            let ret = gio_sys::g_file_replace_finish(_source_object as *mut _, res, &mut error);
2550            let result = if error.is_null() {
2551                Ok(from_glib_full(ret))
2552            } else {
2553                Err(from_glib_full(error))
2554            };
2555            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
2556            callback(result);
2557        }
2558        let callback = replace_async_trampoline::<Q>;
2559        unsafe {
2560            gio_sys::g_file_replace_async(
2561                self.as_ref().to_glib_none().0,
2562                etag.to_glib_none().0,
2563                make_backup.to_glib(),
2564                flags.to_glib(),
2565                io_priority.to_glib(),
2566                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2567                Some(callback),
2568                Box::into_raw(user_data) as *mut _,
2569            );
2570        }
2571    }
2572
2573    #[cfg(feature = "futures")]
2574    fn replace_async_future(
2575        &self,
2576        etag: Option<&str>,
2577        make_backup: bool,
2578        flags: FileCreateFlags,
2579        io_priority: glib::Priority,
2580    ) -> Box_<dyn future::Future<Output = Result<FileOutputStream, Error>> + std::marker::Unpin>
2581    {
2582        use fragile::Fragile;
2583        use GioFuture;
2584
2585        let etag = etag.map(ToOwned::to_owned);
2586        GioFuture::new(self, move |obj, send| {
2587            let cancellable = Cancellable::new();
2588            let send = Fragile::new(send);
2589            obj.replace_async(
2590                etag.as_ref().map(::std::borrow::Borrow::borrow),
2591                make_backup,
2592                flags,
2593                io_priority,
2594                Some(&cancellable),
2595                move |res| {
2596                    let _ = send.into_inner().send(res);
2597                },
2598            );
2599
2600            cancellable
2601        })
2602    }
2603
2604    fn replace_contents<P: IsA<Cancellable>>(
2605        &self,
2606        contents: &[u8],
2607        etag: Option<&str>,
2608        make_backup: bool,
2609        flags: FileCreateFlags,
2610        cancellable: Option<&P>,
2611    ) -> Result<GString, Error> {
2612        let length = contents.len() as usize;
2613        unsafe {
2614            let mut new_etag = ptr::null_mut();
2615            let mut error = ptr::null_mut();
2616            let _ = gio_sys::g_file_replace_contents(
2617                self.as_ref().to_glib_none().0,
2618                contents.to_glib_none().0,
2619                length,
2620                etag.to_glib_none().0,
2621                make_backup.to_glib(),
2622                flags.to_glib(),
2623                &mut new_etag,
2624                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2625                &mut error,
2626            );
2627            if error.is_null() {
2628                Ok(from_glib_full(new_etag))
2629            } else {
2630                Err(from_glib_full(error))
2631            }
2632        }
2633    }
2634
2635    //fn replace_contents_bytes_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + 'static>(&self, contents: &glib::Bytes, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, callback: Q) {
2636    //    unsafe { TODO: call gio_sys:g_file_replace_contents_bytes_async() }
2637    //}
2638
2639    fn replace_readwrite<P: IsA<Cancellable>>(
2640        &self,
2641        etag: Option<&str>,
2642        make_backup: bool,
2643        flags: FileCreateFlags,
2644        cancellable: Option<&P>,
2645    ) -> Result<FileIOStream, Error> {
2646        unsafe {
2647            let mut error = ptr::null_mut();
2648            let ret = gio_sys::g_file_replace_readwrite(
2649                self.as_ref().to_glib_none().0,
2650                etag.to_glib_none().0,
2651                make_backup.to_glib(),
2652                flags.to_glib(),
2653                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2654                &mut error,
2655            );
2656            if error.is_null() {
2657                Ok(from_glib_full(ret))
2658            } else {
2659                Err(from_glib_full(error))
2660            }
2661        }
2662    }
2663
2664    fn replace_readwrite_async<
2665        P: IsA<Cancellable>,
2666        Q: FnOnce(Result<FileIOStream, Error>) + Send + 'static,
2667    >(
2668        &self,
2669        etag: Option<&str>,
2670        make_backup: bool,
2671        flags: FileCreateFlags,
2672        io_priority: glib::Priority,
2673        cancellable: Option<&P>,
2674        callback: Q,
2675    ) {
2676        let user_data: Box<Q> = Box::new(callback);
2677        unsafe extern "C" fn replace_readwrite_async_trampoline<
2678            Q: FnOnce(Result<FileIOStream, Error>) + Send + 'static,
2679        >(
2680            _source_object: *mut gobject_sys::GObject,
2681            res: *mut gio_sys::GAsyncResult,
2682            user_data: glib_sys::gpointer,
2683        ) {
2684            let mut error = ptr::null_mut();
2685            let ret =
2686                gio_sys::g_file_replace_readwrite_finish(_source_object as *mut _, res, &mut error);
2687            let result = if error.is_null() {
2688                Ok(from_glib_full(ret))
2689            } else {
2690                Err(from_glib_full(error))
2691            };
2692            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
2693            callback(result);
2694        }
2695        let callback = replace_readwrite_async_trampoline::<Q>;
2696        unsafe {
2697            gio_sys::g_file_replace_readwrite_async(
2698                self.as_ref().to_glib_none().0,
2699                etag.to_glib_none().0,
2700                make_backup.to_glib(),
2701                flags.to_glib(),
2702                io_priority.to_glib(),
2703                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2704                Some(callback),
2705                Box::into_raw(user_data) as *mut _,
2706            );
2707        }
2708    }
2709
2710    #[cfg(feature = "futures")]
2711    fn replace_readwrite_async_future(
2712        &self,
2713        etag: Option<&str>,
2714        make_backup: bool,
2715        flags: FileCreateFlags,
2716        io_priority: glib::Priority,
2717    ) -> Box_<dyn future::Future<Output = Result<FileIOStream, Error>> + std::marker::Unpin> {
2718        use fragile::Fragile;
2719        use GioFuture;
2720
2721        let etag = etag.map(ToOwned::to_owned);
2722        GioFuture::new(self, move |obj, send| {
2723            let cancellable = Cancellable::new();
2724            let send = Fragile::new(send);
2725            obj.replace_readwrite_async(
2726                etag.as_ref().map(::std::borrow::Borrow::borrow),
2727                make_backup,
2728                flags,
2729                io_priority,
2730                Some(&cancellable),
2731                move |res| {
2732                    let _ = send.into_inner().send(res);
2733                },
2734            );
2735
2736            cancellable
2737        })
2738    }
2739
2740    fn resolve_relative_path<P: AsRef<std::path::Path>>(&self, relative_path: P) -> Option<File> {
2741        unsafe {
2742            from_glib_full(gio_sys::g_file_resolve_relative_path(
2743                self.as_ref().to_glib_none().0,
2744                relative_path.as_ref().to_glib_none().0,
2745            ))
2746        }
2747    }
2748
2749    //fn set_attribute<P: IsA<Cancellable>>(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Option<Fundamental: Pointer>, flags: FileQueryInfoFlags, cancellable: Option<&P>) -> Result<(), Error> {
2750    //    unsafe { TODO: call gio_sys:g_file_set_attribute() }
2751    //}
2752
2753    fn set_attribute_byte_string<P: IsA<Cancellable>>(
2754        &self,
2755        attribute: &str,
2756        value: &str,
2757        flags: FileQueryInfoFlags,
2758        cancellable: Option<&P>,
2759    ) -> Result<(), Error> {
2760        unsafe {
2761            let mut error = ptr::null_mut();
2762            let _ = gio_sys::g_file_set_attribute_byte_string(
2763                self.as_ref().to_glib_none().0,
2764                attribute.to_glib_none().0,
2765                value.to_glib_none().0,
2766                flags.to_glib(),
2767                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2768                &mut error,
2769            );
2770            if error.is_null() {
2771                Ok(())
2772            } else {
2773                Err(from_glib_full(error))
2774            }
2775        }
2776    }
2777
2778    fn set_attribute_int32<P: IsA<Cancellable>>(
2779        &self,
2780        attribute: &str,
2781        value: i32,
2782        flags: FileQueryInfoFlags,
2783        cancellable: Option<&P>,
2784    ) -> Result<(), Error> {
2785        unsafe {
2786            let mut error = ptr::null_mut();
2787            let _ = gio_sys::g_file_set_attribute_int32(
2788                self.as_ref().to_glib_none().0,
2789                attribute.to_glib_none().0,
2790                value,
2791                flags.to_glib(),
2792                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2793                &mut error,
2794            );
2795            if error.is_null() {
2796                Ok(())
2797            } else {
2798                Err(from_glib_full(error))
2799            }
2800        }
2801    }
2802
2803    fn set_attribute_int64<P: IsA<Cancellable>>(
2804        &self,
2805        attribute: &str,
2806        value: i64,
2807        flags: FileQueryInfoFlags,
2808        cancellable: Option<&P>,
2809    ) -> Result<(), Error> {
2810        unsafe {
2811            let mut error = ptr::null_mut();
2812            let _ = gio_sys::g_file_set_attribute_int64(
2813                self.as_ref().to_glib_none().0,
2814                attribute.to_glib_none().0,
2815                value,
2816                flags.to_glib(),
2817                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2818                &mut error,
2819            );
2820            if error.is_null() {
2821                Ok(())
2822            } else {
2823                Err(from_glib_full(error))
2824            }
2825        }
2826    }
2827
2828    fn set_attribute_string<P: IsA<Cancellable>>(
2829        &self,
2830        attribute: &str,
2831        value: &str,
2832        flags: FileQueryInfoFlags,
2833        cancellable: Option<&P>,
2834    ) -> Result<(), Error> {
2835        unsafe {
2836            let mut error = ptr::null_mut();
2837            let _ = gio_sys::g_file_set_attribute_string(
2838                self.as_ref().to_glib_none().0,
2839                attribute.to_glib_none().0,
2840                value.to_glib_none().0,
2841                flags.to_glib(),
2842                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2843                &mut error,
2844            );
2845            if error.is_null() {
2846                Ok(())
2847            } else {
2848                Err(from_glib_full(error))
2849            }
2850        }
2851    }
2852
2853    fn set_attribute_uint32<P: IsA<Cancellable>>(
2854        &self,
2855        attribute: &str,
2856        value: u32,
2857        flags: FileQueryInfoFlags,
2858        cancellable: Option<&P>,
2859    ) -> Result<(), Error> {
2860        unsafe {
2861            let mut error = ptr::null_mut();
2862            let _ = gio_sys::g_file_set_attribute_uint32(
2863                self.as_ref().to_glib_none().0,
2864                attribute.to_glib_none().0,
2865                value,
2866                flags.to_glib(),
2867                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2868                &mut error,
2869            );
2870            if error.is_null() {
2871                Ok(())
2872            } else {
2873                Err(from_glib_full(error))
2874            }
2875        }
2876    }
2877
2878    fn set_attribute_uint64<P: IsA<Cancellable>>(
2879        &self,
2880        attribute: &str,
2881        value: u64,
2882        flags: FileQueryInfoFlags,
2883        cancellable: Option<&P>,
2884    ) -> Result<(), Error> {
2885        unsafe {
2886            let mut error = ptr::null_mut();
2887            let _ = gio_sys::g_file_set_attribute_uint64(
2888                self.as_ref().to_glib_none().0,
2889                attribute.to_glib_none().0,
2890                value,
2891                flags.to_glib(),
2892                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2893                &mut error,
2894            );
2895            if error.is_null() {
2896                Ok(())
2897            } else {
2898                Err(from_glib_full(error))
2899            }
2900        }
2901    }
2902
2903    fn set_attributes_async<
2904        P: IsA<Cancellable>,
2905        Q: FnOnce(Result<FileInfo, Error>) + Send + 'static,
2906    >(
2907        &self,
2908        info: &FileInfo,
2909        flags: FileQueryInfoFlags,
2910        io_priority: glib::Priority,
2911        cancellable: Option<&P>,
2912        callback: Q,
2913    ) {
2914        let user_data: Box<Q> = Box::new(callback);
2915        unsafe extern "C" fn set_attributes_async_trampoline<
2916            Q: FnOnce(Result<FileInfo, Error>) + Send + 'static,
2917        >(
2918            _source_object: *mut gobject_sys::GObject,
2919            res: *mut gio_sys::GAsyncResult,
2920            user_data: glib_sys::gpointer,
2921        ) {
2922            let mut error = ptr::null_mut();
2923            let mut info = ptr::null_mut();
2924            let _ = gio_sys::g_file_set_attributes_finish(
2925                _source_object as *mut _,
2926                res,
2927                &mut info,
2928                &mut error,
2929            );
2930            let result = if error.is_null() {
2931                Ok(from_glib_full(info))
2932            } else {
2933                Err(from_glib_full(error))
2934            };
2935            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
2936            callback(result);
2937        }
2938        let callback = set_attributes_async_trampoline::<Q>;
2939        unsafe {
2940            gio_sys::g_file_set_attributes_async(
2941                self.as_ref().to_glib_none().0,
2942                info.to_glib_none().0,
2943                flags.to_glib(),
2944                io_priority.to_glib(),
2945                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2946                Some(callback),
2947                Box::into_raw(user_data) as *mut _,
2948            );
2949        }
2950    }
2951
2952    #[cfg(feature = "futures")]
2953    fn set_attributes_async_future(
2954        &self,
2955        info: &FileInfo,
2956        flags: FileQueryInfoFlags,
2957        io_priority: glib::Priority,
2958    ) -> Box_<dyn future::Future<Output = Result<FileInfo, Error>> + std::marker::Unpin> {
2959        use fragile::Fragile;
2960        use GioFuture;
2961
2962        let info = info.clone();
2963        GioFuture::new(self, move |obj, send| {
2964            let cancellable = Cancellable::new();
2965            let send = Fragile::new(send);
2966            obj.set_attributes_async(&info, flags, io_priority, Some(&cancellable), move |res| {
2967                let _ = send.into_inner().send(res);
2968            });
2969
2970            cancellable
2971        })
2972    }
2973
2974    fn set_attributes_from_info<P: IsA<Cancellable>>(
2975        &self,
2976        info: &FileInfo,
2977        flags: FileQueryInfoFlags,
2978        cancellable: Option<&P>,
2979    ) -> Result<(), Error> {
2980        unsafe {
2981            let mut error = ptr::null_mut();
2982            let _ = gio_sys::g_file_set_attributes_from_info(
2983                self.as_ref().to_glib_none().0,
2984                info.to_glib_none().0,
2985                flags.to_glib(),
2986                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2987                &mut error,
2988            );
2989            if error.is_null() {
2990                Ok(())
2991            } else {
2992                Err(from_glib_full(error))
2993            }
2994        }
2995    }
2996
2997    fn set_display_name<P: IsA<Cancellable>>(
2998        &self,
2999        display_name: &str,
3000        cancellable: Option<&P>,
3001    ) -> Result<File, Error> {
3002        unsafe {
3003            let mut error = ptr::null_mut();
3004            let ret = gio_sys::g_file_set_display_name(
3005                self.as_ref().to_glib_none().0,
3006                display_name.to_glib_none().0,
3007                cancellable.map(|p| p.as_ref()).to_glib_none().0,
3008                &mut error,
3009            );
3010            if error.is_null() {
3011                Ok(from_glib_full(ret))
3012            } else {
3013                Err(from_glib_full(error))
3014            }
3015        }
3016    }
3017
3018    fn set_display_name_async<
3019        P: IsA<Cancellable>,
3020        Q: FnOnce(Result<File, Error>) + Send + 'static,
3021    >(
3022        &self,
3023        display_name: &str,
3024        io_priority: glib::Priority,
3025        cancellable: Option<&P>,
3026        callback: Q,
3027    ) {
3028        let user_data: Box<Q> = Box::new(callback);
3029        unsafe extern "C" fn set_display_name_async_trampoline<
3030            Q: FnOnce(Result<File, Error>) + Send + 'static,
3031        >(
3032            _source_object: *mut gobject_sys::GObject,
3033            res: *mut gio_sys::GAsyncResult,
3034            user_data: glib_sys::gpointer,
3035        ) {
3036            let mut error = ptr::null_mut();
3037            let ret =
3038                gio_sys::g_file_set_display_name_finish(_source_object as *mut _, res, &mut error);
3039            let result = if error.is_null() {
3040                Ok(from_glib_full(ret))
3041            } else {
3042                Err(from_glib_full(error))
3043            };
3044            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
3045            callback(result);
3046        }
3047        let callback = set_display_name_async_trampoline::<Q>;
3048        unsafe {
3049            gio_sys::g_file_set_display_name_async(
3050                self.as_ref().to_glib_none().0,
3051                display_name.to_glib_none().0,
3052                io_priority.to_glib(),
3053                cancellable.map(|p| p.as_ref()).to_glib_none().0,
3054                Some(callback),
3055                Box::into_raw(user_data) as *mut _,
3056            );
3057        }
3058    }
3059
3060    #[cfg(feature = "futures")]
3061    fn set_display_name_async_future(
3062        &self,
3063        display_name: &str,
3064        io_priority: glib::Priority,
3065    ) -> Box_<dyn future::Future<Output = Result<File, Error>> + std::marker::Unpin> {
3066        use fragile::Fragile;
3067        use GioFuture;
3068
3069        let display_name = String::from(display_name);
3070        GioFuture::new(self, move |obj, send| {
3071            let cancellable = Cancellable::new();
3072            let send = Fragile::new(send);
3073            obj.set_display_name_async(
3074                &display_name,
3075                io_priority,
3076                Some(&cancellable),
3077                move |res| {
3078                    let _ = send.into_inner().send(res);
3079                },
3080            );
3081
3082            cancellable
3083        })
3084    }
3085
3086    fn start_mountable<
3087        P: IsA<MountOperation>,
3088        Q: IsA<Cancellable>,
3089        R: FnOnce(Result<(), Error>) + Send + 'static,
3090    >(
3091        &self,
3092        flags: DriveStartFlags,
3093        start_operation: Option<&P>,
3094        cancellable: Option<&Q>,
3095        callback: R,
3096    ) {
3097        let user_data: Box<R> = Box::new(callback);
3098        unsafe extern "C" fn start_mountable_trampoline<
3099            R: FnOnce(Result<(), Error>) + Send + 'static,
3100        >(
3101            _source_object: *mut gobject_sys::GObject,
3102            res: *mut gio_sys::GAsyncResult,
3103            user_data: glib_sys::gpointer,
3104        ) {
3105            let mut error = ptr::null_mut();
3106            let _ =
3107                gio_sys::g_file_start_mountable_finish(_source_object as *mut _, res, &mut error);
3108            let result = if error.is_null() {
3109                Ok(())
3110            } else {
3111                Err(from_glib_full(error))
3112            };
3113            let callback: Box<R> = Box::from_raw(user_data as *mut _);
3114            callback(result);
3115        }
3116        let callback = start_mountable_trampoline::<R>;
3117        unsafe {
3118            gio_sys::g_file_start_mountable(
3119                self.as_ref().to_glib_none().0,
3120                flags.to_glib(),
3121                start_operation.map(|p| p.as_ref()).to_glib_none().0,
3122                cancellable.map(|p| p.as_ref()).to_glib_none().0,
3123                Some(callback),
3124                Box::into_raw(user_data) as *mut _,
3125            );
3126        }
3127    }
3128
3129    #[cfg(feature = "futures")]
3130    fn start_mountable_future<P: IsA<MountOperation> + Clone + 'static>(
3131        &self,
3132        flags: DriveStartFlags,
3133        start_operation: Option<&P>,
3134    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
3135        use fragile::Fragile;
3136        use GioFuture;
3137
3138        let start_operation = start_operation.map(ToOwned::to_owned);
3139        GioFuture::new(self, move |obj, send| {
3140            let cancellable = Cancellable::new();
3141            let send = Fragile::new(send);
3142            obj.start_mountable(
3143                flags,
3144                start_operation.as_ref().map(::std::borrow::Borrow::borrow),
3145                Some(&cancellable),
3146                move |res| {
3147                    let _ = send.into_inner().send(res);
3148                },
3149            );
3150
3151            cancellable
3152        })
3153    }
3154
3155    fn stop_mountable<
3156        P: IsA<MountOperation>,
3157        Q: IsA<Cancellable>,
3158        R: FnOnce(Result<(), Error>) + Send + 'static,
3159    >(
3160        &self,
3161        flags: MountUnmountFlags,
3162        mount_operation: Option<&P>,
3163        cancellable: Option<&Q>,
3164        callback: R,
3165    ) {
3166        let user_data: Box<R> = Box::new(callback);
3167        unsafe extern "C" fn stop_mountable_trampoline<
3168            R: FnOnce(Result<(), Error>) + Send + 'static,
3169        >(
3170            _source_object: *mut gobject_sys::GObject,
3171            res: *mut gio_sys::GAsyncResult,
3172            user_data: glib_sys::gpointer,
3173        ) {
3174            let mut error = ptr::null_mut();
3175            let _ =
3176                gio_sys::g_file_stop_mountable_finish(_source_object as *mut _, res, &mut error);
3177            let result = if error.is_null() {
3178                Ok(())
3179            } else {
3180                Err(from_glib_full(error))
3181            };
3182            let callback: Box<R> = Box::from_raw(user_data as *mut _);
3183            callback(result);
3184        }
3185        let callback = stop_mountable_trampoline::<R>;
3186        unsafe {
3187            gio_sys::g_file_stop_mountable(
3188                self.as_ref().to_glib_none().0,
3189                flags.to_glib(),
3190                mount_operation.map(|p| p.as_ref()).to_glib_none().0,
3191                cancellable.map(|p| p.as_ref()).to_glib_none().0,
3192                Some(callback),
3193                Box::into_raw(user_data) as *mut _,
3194            );
3195        }
3196    }
3197
3198    #[cfg(feature = "futures")]
3199    fn stop_mountable_future<P: IsA<MountOperation> + Clone + 'static>(
3200        &self,
3201        flags: MountUnmountFlags,
3202        mount_operation: Option<&P>,
3203    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
3204        use fragile::Fragile;
3205        use GioFuture;
3206
3207        let mount_operation = mount_operation.map(ToOwned::to_owned);
3208        GioFuture::new(self, move |obj, send| {
3209            let cancellable = Cancellable::new();
3210            let send = Fragile::new(send);
3211            obj.stop_mountable(
3212                flags,
3213                mount_operation.as_ref().map(::std::borrow::Borrow::borrow),
3214                Some(&cancellable),
3215                move |res| {
3216                    let _ = send.into_inner().send(res);
3217                },
3218            );
3219
3220            cancellable
3221        })
3222    }
3223
3224    fn supports_thread_contexts(&self) -> bool {
3225        unsafe {
3226            from_glib(gio_sys::g_file_supports_thread_contexts(
3227                self.as_ref().to_glib_none().0,
3228            ))
3229        }
3230    }
3231
3232    fn trash<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), Error> {
3233        unsafe {
3234            let mut error = ptr::null_mut();
3235            let _ = gio_sys::g_file_trash(
3236                self.as_ref().to_glib_none().0,
3237                cancellable.map(|p| p.as_ref()).to_glib_none().0,
3238                &mut error,
3239            );
3240            if error.is_null() {
3241                Ok(())
3242            } else {
3243                Err(from_glib_full(error))
3244            }
3245        }
3246    }
3247
3248    fn trash_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), Error>) + Send + 'static>(
3249        &self,
3250        io_priority: glib::Priority,
3251        cancellable: Option<&P>,
3252        callback: Q,
3253    ) {
3254        let user_data: Box<Q> = Box::new(callback);
3255        unsafe extern "C" fn trash_async_trampoline<
3256            Q: FnOnce(Result<(), Error>) + Send + 'static,
3257        >(
3258            _source_object: *mut gobject_sys::GObject,
3259            res: *mut gio_sys::GAsyncResult,
3260            user_data: glib_sys::gpointer,
3261        ) {
3262            let mut error = ptr::null_mut();
3263            let _ = gio_sys::g_file_trash_finish(_source_object as *mut _, res, &mut error);
3264            let result = if error.is_null() {
3265                Ok(())
3266            } else {
3267                Err(from_glib_full(error))
3268            };
3269            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
3270            callback(result);
3271        }
3272        let callback = trash_async_trampoline::<Q>;
3273        unsafe {
3274            gio_sys::g_file_trash_async(
3275                self.as_ref().to_glib_none().0,
3276                io_priority.to_glib(),
3277                cancellable.map(|p| p.as_ref()).to_glib_none().0,
3278                Some(callback),
3279                Box::into_raw(user_data) as *mut _,
3280            );
3281        }
3282    }
3283
3284    #[cfg(feature = "futures")]
3285    fn trash_async_future(
3286        &self,
3287        io_priority: glib::Priority,
3288    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
3289        use fragile::Fragile;
3290        use GioFuture;
3291
3292        GioFuture::new(self, move |obj, send| {
3293            let cancellable = Cancellable::new();
3294            let send = Fragile::new(send);
3295            obj.trash_async(io_priority, Some(&cancellable), move |res| {
3296                let _ = send.into_inner().send(res);
3297            });
3298
3299            cancellable
3300        })
3301    }
3302
3303    fn unmount_mountable_with_operation<
3304        P: IsA<MountOperation>,
3305        Q: IsA<Cancellable>,
3306        R: FnOnce(Result<(), Error>) + Send + 'static,
3307    >(
3308        &self,
3309        flags: MountUnmountFlags,
3310        mount_operation: Option<&P>,
3311        cancellable: Option<&Q>,
3312        callback: R,
3313    ) {
3314        let user_data: Box<R> = Box::new(callback);
3315        unsafe extern "C" fn unmount_mountable_with_operation_trampoline<
3316            R: FnOnce(Result<(), Error>) + Send + 'static,
3317        >(
3318            _source_object: *mut gobject_sys::GObject,
3319            res: *mut gio_sys::GAsyncResult,
3320            user_data: glib_sys::gpointer,
3321        ) {
3322            let mut error = ptr::null_mut();
3323            let _ = gio_sys::g_file_unmount_mountable_with_operation_finish(
3324                _source_object as *mut _,
3325                res,
3326                &mut error,
3327            );
3328            let result = if error.is_null() {
3329                Ok(())
3330            } else {
3331                Err(from_glib_full(error))
3332            };
3333            let callback: Box<R> = Box::from_raw(user_data as *mut _);
3334            callback(result);
3335        }
3336        let callback = unmount_mountable_with_operation_trampoline::<R>;
3337        unsafe {
3338            gio_sys::g_file_unmount_mountable_with_operation(
3339                self.as_ref().to_glib_none().0,
3340                flags.to_glib(),
3341                mount_operation.map(|p| p.as_ref()).to_glib_none().0,
3342                cancellable.map(|p| p.as_ref()).to_glib_none().0,
3343                Some(callback),
3344                Box::into_raw(user_data) as *mut _,
3345            );
3346        }
3347    }
3348
3349    #[cfg(feature = "futures")]
3350    fn unmount_mountable_with_operation_future<P: IsA<MountOperation> + Clone + 'static>(
3351        &self,
3352        flags: MountUnmountFlags,
3353        mount_operation: Option<&P>,
3354    ) -> Box_<dyn future::Future<Output = Result<(), Error>> + std::marker::Unpin> {
3355        use fragile::Fragile;
3356        use GioFuture;
3357
3358        let mount_operation = mount_operation.map(ToOwned::to_owned);
3359        GioFuture::new(self, move |obj, send| {
3360            let cancellable = Cancellable::new();
3361            let send = Fragile::new(send);
3362            obj.unmount_mountable_with_operation(
3363                flags,
3364                mount_operation.as_ref().map(::std::borrow::Borrow::borrow),
3365                Some(&cancellable),
3366                move |res| {
3367                    let _ = send.into_inner().send(res);
3368                },
3369            );
3370
3371            cancellable
3372        })
3373    }
3374}
3375
3376impl fmt::Display for File {
3377    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3378        write!(f, "File")
3379    }
3380}