Trait gio::prelude::FileExtManual

source ·
pub trait FileExtManual: Sealed + IsA<File> + Sized {
Show 17 methods // Provided methods fn replace_contents_async<B: AsRef<[u8]> + Send + 'static, R: FnOnce(Result<(B, GString), (B, Error)>) + 'static, C: IsA<Cancellable>>( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&C>, callback: R, ) { ... } fn replace_contents_future<B: AsRef<[u8]> + Send + 'static>( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, ) -> Pin<Box<dyn Future<Output = Result<(B, GString), (B, Error)>> + 'static>> { ... } fn enumerate_children_async<P: IsA<Cancellable>, Q: FnOnce(Result<FileEnumerator, Error>) + 'static>( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: Priority, cancellable: Option<&P>, callback: Q, ) { ... } fn enumerate_children_future( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: Priority, ) -> Pin<Box<dyn Future<Output = Result<FileEnumerator, Error>> + 'static>> { ... } fn copy_async<Q: FnOnce(Result<(), Error>) + 'static>( &self, destination: &impl IsA<File>, flags: FileCopyFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, progress_callback: Option<Box<dyn FnMut(i64, i64)>>, callback: Q, ) { ... } fn copy_future( &self, destination: &(impl IsA<File> + Clone + 'static), flags: FileCopyFlags, io_priority: Priority, ) -> (Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>>, Pin<Box<dyn Stream<Item = (i64, i64)> + 'static>>) { ... } fn load_contents( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(Slice<u8>, Option<GString>), Error> { ... } fn load_contents_async<P: FnOnce(Result<(Slice<u8>, Option<GString>), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, ) { ... } fn load_contents_future( &self, ) -> Pin<Box<dyn Future<Output = Result<(Slice<u8>, Option<GString>), Error>> + 'static>> { ... } fn load_partial_contents_async<P: FnMut(&[u8]) -> bool + 'static, Q: FnOnce(Result<(Slice<u8>, Option<GString>), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, read_more_callback: P, callback: Q, ) { ... } fn measure_disk_usage( &self, flags: FileMeasureFlags, cancellable: Option<&impl IsA<Cancellable>>, progress_callback: Option<Box<dyn FnMut(bool, u64, u64, u64) + 'static>>, ) -> Result<(u64, u64, u64), Error> { ... } fn measure_disk_usage_async<P: FnOnce(Result<(u64, u64, u64), Error>) + 'static>( &self, flags: FileMeasureFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, progress_callback: Option<Box<dyn FnMut(bool, u64, u64, u64) + 'static>>, callback: P, ) { ... } fn measure_disk_usage_future( &self, flags: FileMeasureFlags, io_priority: Priority, ) -> (Pin<Box<dyn Future<Output = Result<(u64, u64, u64), Error>> + 'static>>, Pin<Box<dyn Stream<Item = (bool, u64, u64, u64)> + 'static>>) { ... } fn move_async<Q: FnOnce(Result<(), Error>) + 'static>( &self, destination: &impl IsA<File>, flags: FileCopyFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, progress_callback: Option<Box<dyn FnMut(i64, i64)>>, callback: Q, ) { ... } fn make_symbolic_link_async<P: FnOnce(Result<(), Error>) + 'static>( &self, symlink_value: impl AsRef<Path>, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, ) { ... } fn make_symbolic_link_future( &self, symlink_value: impl AsRef<Path>, io_priority: Priority, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>> { ... } fn move_future( &self, destination: &(impl IsA<File> + Clone + 'static), flags: FileCopyFlags, io_priority: Priority, ) -> (Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>>, Pin<Box<dyn Stream<Item = (i64, i64)> + 'static>>) { ... }
}

Provided Methods§

source

fn replace_contents_async<B: AsRef<[u8]> + Send + 'static, R: FnOnce(Result<(B, GString), (B, Error)>) + 'static, C: IsA<Cancellable>>( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&C>, callback: R, )

Starts an asynchronous replacement of @self with the given @contents of @length bytes. @etag will replace the document’s current entity tag.

When this operation has completed, @callback will be called with @user_user data, and the operation can be finalized with g_file_replace_contents_finish().

If @cancellable is not None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnum::Cancelled will be returned.

If @make_backup is true, this function will attempt to make a backup of @self.

Note that no copy of @contents will be made, so it must stay valid until @callback is called. See g_file_replace_contents_bytes_async() for a #GBytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.

§contents

string of contents to replace the file with

§etag

a new entity tag for the @self, or None

§make_backup

true if a backup should be created

§flags

a set of #GFileCreateFlags

§cancellable

optional #GCancellable object, None to ignore

§callback

a #GAsyncReadyCallback to call when the request is satisfied

source

fn replace_contents_future<B: AsRef<[u8]> + Send + 'static>( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, ) -> Pin<Box<dyn Future<Output = Result<(B, GString), (B, Error)>> + 'static>>

source

fn enumerate_children_async<P: IsA<Cancellable>, Q: FnOnce(Result<FileEnumerator, Error>) + 'static>( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: Priority, cancellable: Option<&P>, callback: Q, )

source

fn enumerate_children_future( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: Priority, ) -> Pin<Box<dyn Future<Output = Result<FileEnumerator, Error>> + 'static>>

source

fn copy_async<Q: FnOnce(Result<(), Error>) + 'static>( &self, destination: &impl IsA<File>, flags: FileCopyFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, progress_callback: Option<Box<dyn FnMut(i64, i64)>>, callback: Q, )

Copies the file @self to the location specified by @destination asynchronously. For details of the behaviour, see g_file_copy().

If @progress_callback is not None, then that function that will be called just like in g_file_copy(). The callback will run in the default main context of the thread calling g_file_copy_async() — the same context as @callback is run in.

When the operation is finished, @callback will be called. You can then call g_file_copy_finish() to get the result of the operation.

§destination

destination #GFile

§flags

set of #GFileCopyFlags

§io_priority

the [I/O priority][io-priority] of the request

§cancellable

optional #GCancellable object, None to ignore

§progress_callback

function to callback with progress information, or None if progress information is not needed

§progress_callback_data

user data to pass to @progress_callback

§callback

a #GAsyncReadyCallback to call when the request is satisfied

source

fn copy_future( &self, destination: &(impl IsA<File> + Clone + 'static), flags: FileCopyFlags, io_priority: Priority, ) -> (Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>>, Pin<Box<dyn Stream<Item = (i64, i64)> + 'static>>)

source

fn load_contents( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(Slice<u8>, Option<GString>), Error>

Loads the content of the file into memory. The data is always zero-terminated, but this is not included in the resultant @length. The returned @contents should be freed with g_free() when no longer needed.

If @cancellable is not None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnum::Cancelled will be returned.

§cancellable

optional #GCancellable object, None to ignore

§Returns

true if the @self’s contents were successfully loaded. false if there were errors.

§contents

a location to place the contents of the file

§etag_out

a location to place the current entity tag for the file, or None if the entity tag is not needed

source

fn load_contents_async<P: FnOnce(Result<(Slice<u8>, Option<GString>), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Starts an asynchronous load of the @self’s contents.

For more details, see g_file_load_contents() which is the synchronous version of this call.

When the load operation has completed, @callback will be called with @user data. To finish the operation, call g_file_load_contents_finish() with the #GAsyncResult returned by the @callback.

If @cancellable is not None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnum::Cancelled will be returned.

§cancellable

optional #GCancellable object, None to ignore

§callback

a #GAsyncReadyCallback to call when the request is satisfied

source

fn load_contents_future( &self, ) -> Pin<Box<dyn Future<Output = Result<(Slice<u8>, Option<GString>), Error>> + 'static>>

source

fn load_partial_contents_async<P: FnMut(&[u8]) -> bool + 'static, Q: FnOnce(Result<(Slice<u8>, Option<GString>), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, read_more_callback: P, callback: Q, )

Reads the partial contents of a file. A #GFileReadMoreCallback should be used to stop reading from the file when appropriate, else this function will behave exactly as g_file_load_contents_async(). This operation can be finished by g_file_load_partial_contents_finish().

Users of this function should be aware that @user_data is passed to both the @read_more_callback and the @callback.

If @cancellable is not None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IOErrorEnum::Cancelled will be returned.

§cancellable

optional #GCancellable object, None to ignore

§read_more_callback

a #GFileReadMoreCallback to receive partial data and to specify whether further data should be read

§callback

a #GAsyncReadyCallback to call when the request is satisfied

source

fn measure_disk_usage( &self, flags: FileMeasureFlags, cancellable: Option<&impl IsA<Cancellable>>, progress_callback: Option<Box<dyn FnMut(bool, u64, u64, u64) + 'static>>, ) -> Result<(u64, u64, u64), Error>

Recursively measures the disk usage of @self.

This is essentially an analog of the ‘du’ command, but it also reports the number of directories and non-directory files encountered (including things like symbolic links).

By default, errors are only reported against the toplevel file itself. Errors found while recursing are silently ignored, unless FileMeasureFlags::REPORT_ANY_ERROR is given in @flags.

The returned size, @disk_usage, is in bytes and should be formatted with g_format_size() in order to get something reasonable for showing in a user interface.

@progress_callback and @progress_data can be given to request periodic progress updates while scanning. See the documentation for #GFileMeasureProgressCallback for information about when and how the callback will be invoked.

§flags

#GFileMeasureFlags

§cancellable

optional #GCancellable

§progress_callback

a #GFileMeasureProgressCallback

§progress_data

user_data for @progress_callback

§Returns

true if successful, with the out parameters set. false otherwise, with @error set.

§disk_usage

the number of bytes of disk space used

§num_dirs

the number of directories encountered

§num_files

the number of non-directories encountered

source

fn measure_disk_usage_async<P: FnOnce(Result<(u64, u64, u64), Error>) + 'static>( &self, flags: FileMeasureFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, progress_callback: Option<Box<dyn FnMut(bool, u64, u64, u64) + 'static>>, callback: P, )

Recursively measures the disk usage of @self.

This is the asynchronous version of g_file_measure_disk_usage(). See there for more information.

§flags

#GFileMeasureFlags

§io_priority

the [I/O priority][io-priority] of the request

§cancellable

optional #GCancellable

§progress_callback

a #GFileMeasureProgressCallback

§progress_data

user_data for @progress_callback

§callback

a #GAsyncReadyCallback to call when complete

source

fn measure_disk_usage_future( &self, flags: FileMeasureFlags, io_priority: Priority, ) -> (Pin<Box<dyn Future<Output = Result<(u64, u64, u64), Error>> + 'static>>, Pin<Box<dyn Stream<Item = (bool, u64, u64, u64)> + 'static>>)

source

fn move_async<Q: FnOnce(Result<(), Error>) + 'static>( &self, destination: &impl IsA<File>, flags: FileCopyFlags, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, progress_callback: Option<Box<dyn FnMut(i64, i64)>>, callback: Q, )

Available on crate feature v2_72 only.

Asynchronously moves a file @self to the location of @destination. For details of the behaviour, see g_file_move().

If @progress_callback is not None, then that function that will be called just like in g_file_move(). The callback will run in the default main context of the thread calling g_file_move_async() — the same context as @callback is run in.

When the operation is finished, @callback will be called. You can then call g_file_move_finish() to get the result of the operation.

§destination

#GFile pointing to the destination location

§flags

set of #GFileCopyFlags

§io_priority

the [I/O priority][io-priority] of the request

§cancellable

optional #GCancellable object, None to ignore

§progress_callback

#GFileProgressCallback function for updates

§progress_callback_data

gpointer to user data for the callback function

§callback

a #GAsyncReadyCallback to call when the request is satisfied

Available on crate feature v2_74 only.

Asynchronously creates a symbolic link named @self which contains the string @symlink_value.

a string with the path for the target of the new symlink

§io_priority

the [I/O priority][io-priority] of the request

§cancellable

optional #GCancellable object, None to ignore

§callback

a #GAsyncReadyCallback to call when the request is satisfied

Available on crate feature v2_74 only.
source

fn move_future( &self, destination: &(impl IsA<File> + Clone + 'static), flags: FileCopyFlags, io_priority: Priority, ) -> (Pin<Box<dyn Future<Output = Result<(), Error>> + 'static>>, Pin<Box<dyn Stream<Item = (i64, i64)> + 'static>>)

Available on crate feature v2_72 only.

Object Safety§

This trait is not object safe.

Implementors§