[][src]Trait gio::VfsExt

pub trait VfsExt: 'static {
    fn get_file_for_path(&self, path: &str) -> Option<File>;
fn get_file_for_uri(&self, uri: &str) -> Option<File>;
fn get_supported_uri_schemes(&self) -> Vec<GString>;
fn is_active(&self) -> bool;
fn parse_name(&self, parse_name: &str) -> Option<File>;
fn register_uri_scheme(
        &self,
        scheme: &str,
        uri_func: Option<Box_<dyn Fn(&Vfs, &str) -> File + 'static>>,
        parse_name_func: Option<Box_<dyn Fn(&Vfs, &str) -> File + 'static>>
    ) -> bool;
fn unregister_uri_scheme(&self, scheme: &str) -> bool; }

Trait containing all Vfs methods.

Implementors

Vfs

Required methods

fn get_file_for_path(&self, path: &str) -> Option<File>

Gets a File for path.

path

a string containing a VFS path.

Returns

a File. Free the returned object with gobject::ObjectExt::unref.

fn get_file_for_uri(&self, uri: &str) -> Option<File>

Gets a File for uri.

This operation never fails, but the returned object might not support any I/O operation if the URI is malformed or if the URI scheme is not supported.

uri

a string containing a URI

Returns

a File. Free the returned object with gobject::ObjectExt::unref.

fn get_supported_uri_schemes(&self) -> Vec<GString>

Gets a list of URI schemes supported by self.

Returns

a None-terminated array of strings. The returned array belongs to GIO and must not be freed or modified.

fn is_active(&self) -> bool

Checks if the VFS is active.

Returns

true if construction of the self was successful and it is now active.

fn parse_name(&self, parse_name: &str) -> Option<File>

This operation never fails, but the returned object might not support any I/O operations if the parse_name cannot be parsed by the Vfs module.

parse_name

a string to be parsed by the VFS module.

Returns

a File for the given parse_name. Free the returned object with gobject::ObjectExt::unref.

fn register_uri_scheme(
    &self,
    scheme: &str,
    uri_func: Option<Box_<dyn Fn(&Vfs, &str) -> File + 'static>>,
    parse_name_func: Option<Box_<dyn Fn(&Vfs, &str) -> File + 'static>>
) -> bool

Registers uri_func and parse_name_func as the File URI and parse name lookup functions for URIs with a scheme matching scheme. Note that scheme is registered only within the running application, as opposed to desktop-wide as it happens with GVfs backends.

When a File is requested with an URI containing scheme (e.g. through File::new_for_uri), uri_func will be called to allow a custom constructor. The implementation of uri_func should not be blocking, and must not call VfsExt::register_uri_scheme or VfsExt::unregister_uri_scheme.

When File::parse_name is called with a parse name obtained from such file, parse_name_func will be called to allow the File to be created again. In that case, it's responsibility of parse_name_func to make sure the parse name matches what the custom File implementation returned when File::get_parse_name was previously called. The implementation of parse_name_func should not be blocking, and must not call VfsExt::register_uri_scheme or VfsExt::unregister_uri_scheme.

It's an error to call this function twice with the same scheme. To unregister a custom URI scheme, use VfsExt::unregister_uri_scheme.

Feature: v2_50

scheme

an URI scheme, e.g. "http"

uri_func

a GVfsFileLookupFunc

uri_data

custom data passed to be passed to uri_func, or None

uri_destroy

function to be called when unregistering the URI scheme, or when self is disposed, to free the resources used by the URI lookup function

parse_name_func

a GVfsFileLookupFunc

parse_name_data

custom data passed to be passed to parse_name_func, or None

parse_name_destroy

function to be called when unregistering the URI scheme, or when self is disposed, to free the resources used by the parse name lookup function

Returns

true if scheme was successfully registered, or false if a handler for scheme already exists.

fn unregister_uri_scheme(&self, scheme: &str) -> bool

Unregisters the URI handler for scheme previously registered with VfsExt::register_uri_scheme.

Feature: v2_50

scheme

an URI scheme, e.g. "http"

Returns

true if scheme was successfully unregistered, or false if a handler for scheme does not exist.

Loading content...

Implementors

impl<O: IsA<Vfs>> VfsExt for O[src]

Loading content...