Struct glib::Uri

source ·
pub struct Uri { /* private fields */ }
Available on crate feature v2_66 only.
Expand description

The GUri type and related functions can be used to parse URIs into their components, and build valid URIs from individual components.

Since GUri only represents absolute URIs, all GUris will have a URI scheme, so scheme() will always return a non-NULL answer. Likewise, by definition, all URIs have a path component, so path() will always return a non-NULL string (which may be empty).

If the URI string has an ‘authority’ component (that is, if the scheme is followed by :// rather than just :), then the GUri will contain a hostname, and possibly a port and ‘userinfo’. Additionally, depending on how the GUri was constructed/parsed (for example, using the G_URI_FLAGS_HAS_PASSWORD and G_URI_FLAGS_HAS_AUTH_PARAMS flags), the userinfo may be split out into a username, password, and additional authorization-related parameters.

Normally, the components of a GUri will have all %-encoded characters decoded. However, if you construct/parse a GUri with G_URI_FLAGS_ENCODED, then the %-encoding will be preserved instead in the userinfo, path, and query fields (and in the host field if also created with G_URI_FLAGS_NON_DNS). In particular, this is necessary if the URI may contain binary data or non-UTF-8 text, or if decoding the components might change the interpretation of the URI.

For example, with the encoded flag:

⚠️ The following code is in c ⚠️

g_autoptr(GUri) uri = g_uri_parse ("http://host/path?query=http%3A%2F%2Fhost%2Fpath%3Fparam%3Dvalue", G_URI_FLAGS_ENCODED, &err);
g_assert_cmpstr (g_uri_get_query (uri), ==, "query=http%3A%2F%2Fhost%2Fpath%3Fparam%3Dvalue");

While the default %-decoding behaviour would give:

⚠️ The following code is in c ⚠️

g_autoptr(GUri) uri = g_uri_parse ("http://host/path?query=http%3A%2F%2Fhost%2Fpath%3Fparam%3Dvalue", G_URI_FLAGS_NONE, &err);
g_assert_cmpstr (g_uri_get_query (uri), ==, "query=http://host/path?param=value");

During decoding, if an invalid UTF-8 string is encountered, parsing will fail with an error indicating the bad string location:

⚠️ The following code is in c ⚠️

g_autoptr(GUri) uri = g_uri_parse ("http://host/path?query=http%3A%2F%2Fhost%2Fpath%3Fbad%3D%00alue", G_URI_FLAGS_NONE, &err);
g_assert_error (err, G_URI_ERROR, G_URI_ERROR_BAD_QUERY);

You should pass G_URI_FLAGS_ENCODED or G_URI_FLAGS_ENCODED_QUERY if you need to handle that case manually. In particular, if the query string contains = characters that are %-encoded, you should let GLib::Uri::parse_params() do the decoding once of the query.

GUri is immutable once constructed, and can safely be accessed from multiple threads. Its reference counting is atomic.

Note that the scope of GUri is to help manipulate URIs in various applications, following RFC 3986. In particular, it doesn’t intend to cover web browser needs, and doesn’t implement the WHATWG URL standard. No APIs are provided to help prevent homograph attacks, so GUri is not suitable for formatting URIs for display to the user for making security-sensitive decisions.

§Relative and absolute URIs

As defined in RFC 3986, the hierarchical nature of URIs means that they can either be ‘relative references’ (sometimes referred to as ‘relative URIs’) or ‘URIs’ (for clarity, ‘URIs’ are referred to in this documentation as ‘absolute URIs’ — although in contrast to RFC 3986, fragment identifiers are always allowed).

Relative references have one or more components of the URI missing. In particular, they have no scheme. Any other component, such as hostname, query, etc. may be missing, apart from a path, which has to be specified (but may be empty). The path may be relative, starting with ./ rather than /.

For example, a valid relative reference is ./path?query, /?query#fragment or //example.com.

Absolute URIs have a scheme specified. Any other components of the URI which are missing are specified as explicitly unset in the URI, rather than being resolved relative to a base URI using parse_relative().

For example, a valid absolute URI is file:///home/bob or https://search.com?query=string.

A GUri instance is always an absolute URI. A string may be an absolute URI or a relative reference; see the documentation for individual functions as to what forms they accept.

§Parsing URIs

The most minimalist APIs for parsing URIs are split() and split_with_user(). These split a URI into its component parts, and return the parts; the difference between the two is that split() treats the ‘userinfo’ component of the URI as a single element, while split_with_user() can (depending on the UriFlags you pass) treat it as containing a username, password, and authentication parameters. Alternatively, split_network() can be used when you are only interested in the components that are needed to initiate a network connection to the service (scheme, host, and port).

parse() is similar to split(), but instead of returning individual strings, it returns a GUri structure (and it requires that the URI be an absolute URI).

resolve_relative() and parse_relative() allow you to resolve a relative URI relative to a base URI. resolve_relative() takes two strings and returns a string, and parse_relative() takes a GUri and a string and returns a GUri.

All of the parsing functions take a UriFlags argument describing exactly how to parse the URI; see the documentation for that type for more details on the specific flags that you can pass. If you need to choose different flags based on the type of URI, you can use peek_scheme() on the URI string to check the scheme first, and use that to decide what flags to parse it with.

For example, you might want to use G_URI_PARAMS_WWW_FORM when parsing the params for a web URI, so compare the result of peek_scheme() against http and https.

§Building URIs

join() and join_with_user() can be used to construct valid URI strings from a set of component strings. They are the inverse of split() and split_with_user().

Similarly, build() and build_with_user() can be used to construct a GUri from a set of component strings.

As with the parsing functions, the building functions take a UriFlags argument. In particular, it is important to keep in mind whether the URI components you are using are already %-encoded. If so, you must pass the G_URI_FLAGS_ENCODED flag.

§file:// URIs

Note that Windows and Unix both define special rules for parsing file:// URIs (involving non-UTF-8 character sets on Unix, and the interpretation of path separators on Windows). GUri does not implement these rules. Use filename_from_uri() and filename_to_uri() if you want to properly convert between file:// URIs and local filenames.

§URI Equality

Note that there is no g_uri_equal () function, because comparing URIs usefully requires scheme-specific knowledge that GUri does not have. GUri can help with normalization if you use the various encoded UriFlags as well as G_URI_FLAGS_SCHEME_NORMALIZE however it is not comprehensive. For example, data:,foo and data:;base64,Zm9v resolve to the same thing according to the data: URI specification which GLib does not handle. The GUri type and related functions can be used to parse URIs into their components, and build valid URIs from individual components.

Since GUri only represents absolute URIs, all GUris will have a URI scheme, so scheme() will always return a non-NULL answer. Likewise, by definition, all URIs have a path component, so path() will always return a non-NULL string (which may be empty).

If the URI string has an ‘authority’ component (that is, if the scheme is followed by :// rather than just :), then the GUri will contain a hostname, and possibly a port and ‘userinfo’. Additionally, depending on how the GUri was constructed/parsed (for example, using the G_URI_FLAGS_HAS_PASSWORD and G_URI_FLAGS_HAS_AUTH_PARAMS flags), the userinfo may be split out into a username, password, and additional authorization-related parameters.

Normally, the components of a GUri will have all %-encoded characters decoded. However, if you construct/parse a GUri with G_URI_FLAGS_ENCODED, then the %-encoding will be preserved instead in the userinfo, path, and query fields (and in the host field if also created with G_URI_FLAGS_NON_DNS). In particular, this is necessary if the URI may contain binary data or non-UTF-8 text, or if decoding the components might change the interpretation of the URI.

For example, with the encoded flag:

⚠️ The following code is in c ⚠️

g_autoptr(GUri) uri = g_uri_parse ("http://host/path?query=http%3A%2F%2Fhost%2Fpath%3Fparam%3Dvalue", G_URI_FLAGS_ENCODED, &err);
g_assert_cmpstr (g_uri_get_query (uri), ==, "query=http%3A%2F%2Fhost%2Fpath%3Fparam%3Dvalue");

While the default %-decoding behaviour would give:

⚠️ The following code is in c ⚠️

g_autoptr(GUri) uri = g_uri_parse ("http://host/path?query=http%3A%2F%2Fhost%2Fpath%3Fparam%3Dvalue", G_URI_FLAGS_NONE, &err);
g_assert_cmpstr (g_uri_get_query (uri), ==, "query=http://host/path?param=value");

During decoding, if an invalid UTF-8 string is encountered, parsing will fail with an error indicating the bad string location:

⚠️ The following code is in c ⚠️

g_autoptr(GUri) uri = g_uri_parse ("http://host/path?query=http%3A%2F%2Fhost%2Fpath%3Fbad%3D%00alue", G_URI_FLAGS_NONE, &err);
g_assert_error (err, G_URI_ERROR, G_URI_ERROR_BAD_QUERY);

You should pass G_URI_FLAGS_ENCODED or G_URI_FLAGS_ENCODED_QUERY if you need to handle that case manually. In particular, if the query string contains = characters that are %-encoded, you should let GLib::Uri::parse_params() do the decoding once of the query.

GUri is immutable once constructed, and can safely be accessed from multiple threads. Its reference counting is atomic.

Note that the scope of GUri is to help manipulate URIs in various applications, following RFC 3986. In particular, it doesn’t intend to cover web browser needs, and doesn’t implement the WHATWG URL standard. No APIs are provided to help prevent homograph attacks, so GUri is not suitable for formatting URIs for display to the user for making security-sensitive decisions.

§Relative and absolute URIs

As defined in RFC 3986, the hierarchical nature of URIs means that they can either be ‘relative references’ (sometimes referred to as ‘relative URIs’) or ‘URIs’ (for clarity, ‘URIs’ are referred to in this documentation as ‘absolute URIs’ — although in contrast to RFC 3986, fragment identifiers are always allowed).

Relative references have one or more components of the URI missing. In particular, they have no scheme. Any other component, such as hostname, query, etc. may be missing, apart from a path, which has to be specified (but may be empty). The path may be relative, starting with ./ rather than /.

For example, a valid relative reference is ./path?query, /?query#fragment or //example.com.

Absolute URIs have a scheme specified. Any other components of the URI which are missing are specified as explicitly unset in the URI, rather than being resolved relative to a base URI using parse_relative().

For example, a valid absolute URI is file:///home/bob or https://search.com?query=string.

A GUri instance is always an absolute URI. A string may be an absolute URI or a relative reference; see the documentation for individual functions as to what forms they accept.

§Parsing URIs

The most minimalist APIs for parsing URIs are split() and split_with_user(). These split a URI into its component parts, and return the parts; the difference between the two is that split() treats the ‘userinfo’ component of the URI as a single element, while split_with_user() can (depending on the UriFlags you pass) treat it as containing a username, password, and authentication parameters. Alternatively, split_network() can be used when you are only interested in the components that are needed to initiate a network connection to the service (scheme, host, and port).

parse() is similar to split(), but instead of returning individual strings, it returns a GUri structure (and it requires that the URI be an absolute URI).

resolve_relative() and parse_relative() allow you to resolve a relative URI relative to a base URI. resolve_relative() takes two strings and returns a string, and parse_relative() takes a GUri and a string and returns a GUri.

All of the parsing functions take a UriFlags argument describing exactly how to parse the URI; see the documentation for that type for more details on the specific flags that you can pass. If you need to choose different flags based on the type of URI, you can use peek_scheme() on the URI string to check the scheme first, and use that to decide what flags to parse it with.

For example, you might want to use G_URI_PARAMS_WWW_FORM when parsing the params for a web URI, so compare the result of peek_scheme() against http and https.

§Building URIs

join() and join_with_user() can be used to construct valid URI strings from a set of component strings. They are the inverse of split() and split_with_user().

Similarly, build() and build_with_user() can be used to construct a GUri from a set of component strings.

As with the parsing functions, the building functions take a UriFlags argument. In particular, it is important to keep in mind whether the URI components you are using are already %-encoded. If so, you must pass the G_URI_FLAGS_ENCODED flag.

§file:// URIs

Note that Windows and Unix both define special rules for parsing file:// URIs (involving non-UTF-8 character sets on Unix, and the interpretation of path separators on Windows). GUri does not implement these rules. Use filename_from_uri() and filename_to_uri() if you want to properly convert between file:// URIs and local filenames.

§URI Equality

Note that there is no g_uri_equal () function, because comparing URIs usefully requires scheme-specific knowledge that GUri does not have. GUri can help with normalization if you use the various encoded UriFlags as well as G_URI_FLAGS_SCHEME_NORMALIZE however it is not comprehensive. For example, data:,foo and data:;base64,Zm9v resolve to the same thing according to the data: URI specification which GLib does not handle.

GLib type: Shared boxed type with reference counted clone semantics.

Implementations§

source§

impl Uri

source

pub fn as_ptr(&self) -> *mut GUri

Return the inner pointer to the underlying C value.

source

pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GUri) -> &Self

Borrows the underlying C value.

source§

impl Uri

source

pub fn auth_params(&self) -> Option<GString>

Gets @self’s authentication parameters, which may contain %-encoding, depending on the flags with which @self was created. (If @self was not created with UriFlags::HAS_AUTH_PARAMS then this will be None.)

Depending on the URI scheme, g_uri_parse_params() may be useful for further parsing this information.

§Returns

@self’s authentication parameters. Gets @self’s authentication parameters, which may contain %-encoding, depending on the flags with which @self was created. (If @self was not created with UriFlags::HAS_AUTH_PARAMS then this will be None.)

Depending on the URI scheme, g_uri_parse_params() may be useful for further parsing this information.

§Returns

@self’s authentication parameters.

source

pub fn flags(&self) -> UriFlags

Gets @self’s flags set upon construction.

§Returns

@self’s flags. Gets @self’s flags set upon construction.

§Returns

@self’s flags.

source

pub fn fragment(&self) -> Option<GString>

Gets @self’s fragment, which may contain %-encoding, depending on the flags with which @self was created.

§Returns

@self’s fragment. Gets @self’s fragment, which may contain %-encoding, depending on the flags with which @self was created.

§Returns

@self’s fragment.

source

pub fn host(&self) -> Option<GString>

Gets @self’s host. This will never have %-encoded characters, unless it is non-UTF-8 (which can only be the case if @self was created with UriFlags::NON_DNS).

If @self contained an IPv6 address literal, this value will be just that address, without the brackets around it that are necessary in the string form of the URI. Note that in this case there may also be a scope ID attached to the address. Eg, fe80::1234%``em1 (or fe80::1234%``25em1 if the string is still encoded).

§Returns

@self’s host. Gets @self’s host. This will never have %-encoded characters, unless it is non-UTF-8 (which can only be the case if @self was created with UriFlags::NON_DNS).

If @self contained an IPv6 address literal, this value will be just that address, without the brackets around it that are necessary in the string form of the URI. Note that in this case there may also be a scope ID attached to the address. Eg, fe80::1234%``em1 (or fe80::1234%``25em1 if the string is still encoded).

§Returns

@self’s host.

source

pub fn password(&self) -> Option<GString>

Gets @self’s password, which may contain %-encoding, depending on the flags with which @self was created. (If @self was not created with UriFlags::HAS_PASSWORD then this will be None.)

§Returns

@self’s password. Gets @self’s password, which may contain %-encoding, depending on the flags with which @self was created. (If @self was not created with UriFlags::HAS_PASSWORD then this will be None.)

§Returns

@self’s password.

source

pub fn path(&self) -> GString

Gets @self’s path, which may contain %-encoding, depending on the flags with which @self was created.

§Returns

@self’s path. Gets @self’s path, which may contain %-encoding, depending on the flags with which @self was created.

§Returns

@self’s path.

source

pub fn port(&self) -> i32

Gets @self’s port.

§Returns

@self’s port, or -1 if no port was specified. Gets @self’s port.

§Returns

@self’s port, or -1 if no port was specified.

source

pub fn query(&self) -> Option<GString>

Gets @self’s query, which may contain %-encoding, depending on the flags with which @self was created.

For queries consisting of a series of name=value parameters, #GUriParamsIter or g_uri_parse_params() may be useful.

§Returns

@self’s query. Gets @self’s query, which may contain %-encoding, depending on the flags with which @self was created.

For queries consisting of a series of name=value parameters, #GUriParamsIter or g_uri_parse_params() may be useful.

§Returns

@self’s query.

source

pub fn scheme(&self) -> GString

Gets @self’s scheme. Note that this will always be all-lowercase, regardless of the string or strings that @self was created from.

§Returns

@self’s scheme. Gets @self’s scheme. Note that this will always be all-lowercase, regardless of the string or strings that @self was created from.

§Returns

@self’s scheme.

source

pub fn user(&self) -> Option<GString>

Gets the ‘username’ component of @self’s userinfo, which may contain %-encoding, depending on the flags with which @self was created. If @self was not created with UriFlags::HAS_PASSWORD or UriFlags::HAS_AUTH_PARAMS, this is the same as g_uri_get_userinfo().

§Returns

@self’s user. Gets the ‘username’ component of @self’s userinfo, which may contain %-encoding, depending on the flags with which @self was created. If @self was not created with UriFlags::HAS_PASSWORD or UriFlags::HAS_AUTH_PARAMS, this is the same as g_uri_get_userinfo().

§Returns

@self’s user.

source

pub fn userinfo(&self) -> Option<GString>

Gets @self’s userinfo, which may contain %-encoding, depending on the flags with which @self was created.

§Returns

@self’s userinfo. Gets @self’s userinfo, which may contain %-encoding, depending on the flags with which @self was created.

§Returns

@self’s userinfo.

source

pub fn parse_relative( &self, uri_ref: &str, flags: UriFlags, ) -> Result<Uri, Error>

Parses @uri_ref according to @flags and, if it is a relative URI, resolves it relative to @self. If the result is not a valid absolute URI, it will be discarded, and an error returned.

§uri_ref

a string representing a relative or absolute URI

§flags

flags describing how to parse @uri_ref

§Returns

a new #GUri, or NULL on error. Parses @uri_ref according to @flags and, if it is a relative URI, resolves it relative to @self. If the result is not a valid absolute URI, it will be discarded, and an error returned.

§uri_ref

a string representing a relative or absolute URI

§flags

flags describing how to parse @uri_ref

§Returns

a new #GUri, or NULL on error.

source

pub fn to_str(&self) -> GString

Returns a string representing @self.

This is not guaranteed to return a string which is identical to the string that @self was parsed from. However, if the source URI was syntactically correct (according to RFC 3986), and it was parsed with UriFlags::ENCODED, then g_uri_to_string() is guaranteed to return a string which is at least semantically equivalent to the source URI (according to RFC 3986).

If @self might contain sensitive details, such as authentication parameters, or private data in its query string, and the returned string is going to be logged, then consider using g_uri_to_string_partial() to redact parts.

§Returns

a string representing @self, which the caller must free. Returns a string representing @self.

This is not guaranteed to return a string which is identical to the string that @self was parsed from. However, if the source URI was syntactically correct (according to RFC 3986), and it was parsed with UriFlags::ENCODED, then g_uri_to_string() is guaranteed to return a string which is at least semantically equivalent to the source URI (according to RFC 3986).

If @self might contain sensitive details, such as authentication parameters, or private data in its query string, and the returned string is going to be logged, then consider using g_uri_to_string_partial() to redact parts.

§Returns

a string representing @self, which the caller must free.

source

pub fn to_string_partial(&self, flags: UriHideFlags) -> GString

Returns a string representing @self, subject to the options in @flags. See g_uri_to_string() and #GUriHideFlags for more details.

§flags

flags describing what parts of @self to hide

§Returns

a string representing @self, which the caller must free. Returns a string representing @self, subject to the options in @flags. See g_uri_to_string() and #GUriHideFlags for more details.

§flags

flags describing what parts of @self to hide

§Returns

a string representing @self, which the caller must free.

source

pub fn build( flags: UriFlags, scheme: &str, userinfo: Option<&str>, host: Option<&str>, port: i32, path: &str, query: Option<&str>, fragment: Option<&str>, ) -> Uri

Creates a new #GUri from the given components according to @flags.

See also g_uri_build_with_user(), which allows specifying the components of the “userinfo” separately.

§flags

flags describing how to build the #GUri

§scheme

the URI scheme

§userinfo

the userinfo component, or None

§host

the host component, or None

§port

the port, or -1

§path

the path component

§query

the query component, or None

§fragment

the fragment, or None

§Returns

a new #GUri Creates a new #GUri from the given components according to @flags.

See also g_uri_build_with_user(), which allows specifying the components of the “userinfo” separately.

§flags

flags describing how to build the #GUri

§scheme

the URI scheme

§userinfo

the userinfo component, or None

§host

the host component, or None

§port

the port, or -1

§path

the path component

§query

the query component, or None

§fragment

the fragment, or None

§Returns

a new #GUri

source

pub fn build_with_user( flags: UriFlags, scheme: &str, user: Option<&str>, password: Option<&str>, auth_params: Option<&str>, host: Option<&str>, port: i32, path: &str, query: Option<&str>, fragment: Option<&str>, ) -> Uri

Creates a new #GUri from the given components according to @flags (UriFlags::HAS_PASSWORD is added unconditionally). The @flags must be coherent with the passed values, in particular use %-encoded values with UriFlags::ENCODED.

In contrast to g_uri_build(), this allows specifying the components of the ‘userinfo’ field separately. Note that @user must be non-None if either @password or @auth_params is non-None.

§flags

flags describing how to build the #GUri

§scheme

the URI scheme

§user

the user component of the userinfo, or None

§password

the password component of the userinfo, or None

§auth_params

the auth params of the userinfo, or None

§host

the host component, or None

§port

the port, or -1

§path

the path component

§query

the query component, or None

§fragment

the fragment, or None

§Returns

a new #GUri Creates a new #GUri from the given components according to @flags (UriFlags::HAS_PASSWORD is added unconditionally). The @flags must be coherent with the passed values, in particular use %-encoded values with UriFlags::ENCODED.

In contrast to g_uri_build(), this allows specifying the components of the ‘userinfo’ field separately. Note that @user must be non-None if either @password or @auth_params is non-None.

§flags

flags describing how to build the #GUri

§scheme

the URI scheme

§user

the user component of the userinfo, or None

§password

the password component of the userinfo, or None

§auth_params

the auth params of the userinfo, or None

§host

the host component, or None

§port

the port, or -1

§path

the path component

§query

the query component, or None

§fragment

the fragment, or None

§Returns

a new #GUri

source

pub fn escape_bytes( unescaped: &[u8], reserved_chars_allowed: Option<&str>, ) -> GString

Escapes arbitrary data for use in a URI.

Normally all characters that are not ‘unreserved’ (i.e. ASCII alphanumerical characters plus dash, dot, underscore and tilde) are escaped. But if you specify characters in @reserved_chars_allowed they are not escaped. This is useful for the ‘reserved’ characters in the URI specification, since those are allowed unescaped in some portions of a URI.

Though technically incorrect, this will also allow escaping nul bytes as %``00.

§unescaped

the unescaped input data.

§reserved_chars_allowed

a string of reserved characters that are allowed to be used, or None.

§Returns

an escaped version of @unescaped. The returned string should be freed when no longer needed. Escapes arbitrary data for use in a URI.

Normally all characters that are not ‘unreserved’ (i.e. ASCII alphanumerical characters plus dash, dot, underscore and tilde) are escaped. But if you specify characters in @reserved_chars_allowed they are not escaped. This is useful for the ‘reserved’ characters in the URI specification, since those are allowed unescaped in some portions of a URI.

Though technically incorrect, this will also allow escaping nul bytes as %``00.

§unescaped

the unescaped input data.

§reserved_chars_allowed

a string of reserved characters that are allowed to be used, or None.

§Returns

an escaped version of @unescaped. The returned string should be freed when no longer needed.

source

pub fn escape_string( unescaped: &str, reserved_chars_allowed: Option<&str>, allow_utf8: bool, ) -> GString

Escapes a string for use in a URI.

Normally all characters that are not “unreserved” (i.e. ASCII alphanumerical characters plus dash, dot, underscore and tilde) are escaped. But if you specify characters in @reserved_chars_allowed they are not escaped. This is useful for the “reserved” characters in the URI specification, since those are allowed unescaped in some portions of a URI.

§unescaped

the unescaped input string.

§reserved_chars_allowed

a string of reserved characters that are allowed to be used, or None.

§allow_utf8

true if the result can include UTF-8 characters.

§Returns

an escaped version of @unescaped. The returned string should be freed when no longer needed. Escapes a string for use in a URI.

Normally all characters that are not “unreserved” (i.e. ASCII alphanumerical characters plus dash, dot, underscore and tilde) are escaped. But if you specify characters in @reserved_chars_allowed they are not escaped. This is useful for the “reserved” characters in the URI specification, since those are allowed unescaped in some portions of a URI.

§unescaped

the unescaped input string.

§reserved_chars_allowed

a string of reserved characters that are allowed to be used, or None.

§allow_utf8

true if the result can include UTF-8 characters.

§Returns

an escaped version of @unescaped. The returned string should be freed when no longer needed.

source

pub fn is_valid(uri_string: &str, flags: UriFlags) -> Result<(), Error>

Parses @uri_string according to @flags, to determine whether it is a valid absolute URI, i.e. it does not need to be resolved relative to another URI using g_uri_parse_relative().

If it’s not a valid URI, an error is returned explaining how it’s invalid.

See g_uri_split(), and the definition of #GUriFlags, for more information on the effect of @flags.

§uri_string

a string containing an absolute URI

§flags

flags for parsing @uri_string

§Returns

true if @uri_string is a valid absolute URI, false on error. Parses @uri_string according to @flags, to determine whether it is a valid absolute URI, i.e. it does not need to be resolved relative to another URI using g_uri_parse_relative().

If it’s not a valid URI, an error is returned explaining how it’s invalid.

See g_uri_split(), and the definition of #GUriFlags, for more information on the effect of @flags.

§uri_string

a string containing an absolute URI

§flags

flags for parsing @uri_string

§Returns

true if @uri_string is a valid absolute URI, false on error.

source

pub fn join( flags: UriFlags, scheme: Option<&str>, userinfo: Option<&str>, host: Option<&str>, port: i32, path: &str, query: Option<&str>, fragment: Option<&str>, ) -> GString

Joins the given components together according to @flags to create an absolute URI string. @path may not be None (though it may be the empty string).

When @host is present, @path must either be empty or begin with a slash (/) character. When @host is not present, @path cannot begin with two slash characters (//). See RFC 3986, section 3.

See also g_uri_join_with_user(), which allows specifying the components of the ‘userinfo’ separately.

UriFlags::HAS_PASSWORD and UriFlags::HAS_AUTH_PARAMS are ignored if set in @flags.

§flags

flags describing how to build the URI string

§scheme

the URI scheme, or None

§userinfo

the userinfo component, or None

§host

the host component, or None

§port

the port, or -1

§path

the path component

§query

the query component, or None

§fragment

the fragment, or None

§Returns

an absolute URI string Joins the given components together according to @flags to create an absolute URI string. @path may not be None (though it may be the empty string).

When @host is present, @path must either be empty or begin with a slash (/) character. When @host is not present, @path cannot begin with two slash characters (//). See RFC 3986, section 3.

See also g_uri_join_with_user(), which allows specifying the components of the ‘userinfo’ separately.

UriFlags::HAS_PASSWORD and UriFlags::HAS_AUTH_PARAMS are ignored if set in @flags.

§flags

flags describing how to build the URI string

§scheme

the URI scheme, or None

§userinfo

the userinfo component, or None

§host

the host component, or None

§port

the port, or -1

§path

the path component

§query

the query component, or None

§fragment

the fragment, or None

§Returns

an absolute URI string

source

pub fn join_with_user( flags: UriFlags, scheme: Option<&str>, user: Option<&str>, password: Option<&str>, auth_params: Option<&str>, host: Option<&str>, port: i32, path: &str, query: Option<&str>, fragment: Option<&str>, ) -> GString

Joins the given components together according to @flags to create an absolute URI string. @path may not be None (though it may be the empty string).

In contrast to g_uri_join(), this allows specifying the components of the ‘userinfo’ separately. It otherwise behaves the same.

UriFlags::HAS_PASSWORD and UriFlags::HAS_AUTH_PARAMS are ignored if set in @flags.

§flags

flags describing how to build the URI string

§scheme

the URI scheme, or None

§user

the user component of the userinfo, or None

§password

the password component of the userinfo, or None

§auth_params

the auth params of the userinfo, or None

§host

the host component, or None

§port

the port, or -1

§path

the path component

§query

the query component, or None

§fragment

the fragment, or None

§Returns

an absolute URI string Joins the given components together according to @flags to create an absolute URI string. @path may not be None (though it may be the empty string).

In contrast to g_uri_join(), this allows specifying the components of the ‘userinfo’ separately. It otherwise behaves the same.

UriFlags::HAS_PASSWORD and UriFlags::HAS_AUTH_PARAMS are ignored if set in @flags.

§flags

flags describing how to build the URI string

§scheme

the URI scheme, or None

§user

the user component of the userinfo, or None

§password

the password component of the userinfo, or None

§auth_params

the auth params of the userinfo, or None

§host

the host component, or None

§port

the port, or -1

§path

the path component

§query

the query component, or None

§fragment

the fragment, or None

§Returns

an absolute URI string

source

pub fn list_extract_uris(uri_list: &str) -> Vec<GString>

Splits an URI list conforming to the text/uri-list mime type defined in RFC 2483 into individual URIs, discarding any comments. The URIs are not validated.

§uri_list

an URI list

§Returns

a newly allocated None-terminated list of strings holding the individual URIs. The array should be freed with g_strfreev(). Splits an URI list conforming to the text/uri-list mime type defined in RFC 2483 into individual URIs, discarding any comments. The URIs are not validated.

§uri_list

an URI list

§Returns

a newly allocated None-terminated list of strings holding the individual URIs. The array should be freed with g_strfreev().

source

pub fn parse(uri_string: &str, flags: UriFlags) -> Result<Uri, Error>

Parses @uri_string according to @flags. If the result is not a valid absolute URI, it will be discarded, and an error returned.

§uri_string

a string representing an absolute URI

§flags

flags describing how to parse @uri_string

§Returns

a new #GUri, or NULL on error. Parses @uri_string according to @flags. If the result is not a valid absolute URI, it will be discarded, and an error returned.

§uri_string

a string representing an absolute URI

§flags

flags describing how to parse @uri_string

§Returns

a new #GUri, or NULL on error.

source

pub fn parse_scheme(uri: &str) -> Option<GString>

Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

Common schemes include file, https, svn+ssh, etc.

§uri

a valid URI.

§Returns

The ‘scheme’ component of the URI, or None on error. The returned string should be freed when no longer needed. Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

Common schemes include file, https, svn+ssh, etc.

§uri

a valid URI.

§Returns

The ‘scheme’ component of the URI, or None on error. The returned string should be freed when no longer needed.

source

pub fn peek_scheme(uri: &str) -> Option<GString>

Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

Common schemes include file, https, svn+ssh, etc.

Unlike g_uri_parse_scheme(), the returned scheme is normalized to all-lowercase and does not need to be freed.

§uri

a valid URI.

§Returns

The ‘scheme’ component of the URI, or None on error. The returned string is normalized to all-lowercase, and interned via g_intern_string(), so it does not need to be freed. Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

Common schemes include file, https, svn+ssh, etc.

Unlike g_uri_parse_scheme(), the returned scheme is normalized to all-lowercase and does not need to be freed.

§uri

a valid URI.

§Returns

The ‘scheme’ component of the URI, or None on error. The returned string is normalized to all-lowercase, and interned via g_intern_string(), so it does not need to be freed.

source

pub fn resolve_relative( base_uri_string: Option<&str>, uri_ref: &str, flags: UriFlags, ) -> Result<GString, Error>

Parses @uri_ref according to @flags and, if it is a relative URI, resolves it relative to @base_uri_string. If the result is not a valid absolute URI, it will be discarded, and an error returned.

(If @base_uri_string is None, this just returns @uri_ref, or None if @uri_ref is invalid or not absolute.)

§base_uri_string

a string representing a base URI

§uri_ref

a string representing a relative or absolute URI

§flags

flags describing how to parse @uri_ref

§Returns

the resolved URI string, or NULL on error. Parses @uri_ref according to @flags and, if it is a relative URI, resolves it relative to @base_uri_string. If the result is not a valid absolute URI, it will be discarded, and an error returned.

(If @base_uri_string is None, this just returns @uri_ref, or None if @uri_ref is invalid or not absolute.)

§base_uri_string

a string representing a base URI

§uri_ref

a string representing a relative or absolute URI

§flags

flags describing how to parse @uri_ref

§Returns

the resolved URI string, or NULL on error.

source

pub fn split( uri_ref: &str, flags: UriFlags, ) -> Result<(Option<GString>, Option<GString>, Option<GString>, i32, GString, Option<GString>, Option<GString>), Error>

Parses @uri_ref (which can be an absolute or relative URI) according to @flags, and returns the pieces. Any component that doesn’t appear in @uri_ref will be returned as None (but note that all URIs always have a path component, though it may be the empty string).

If @flags contains UriFlags::ENCODED, then %-encoded characters in @uri_ref will remain encoded in the output strings. (If not, then all such characters will be decoded.) Note that decoding will only work if the URI components are ASCII or UTF-8, so you will need to use UriFlags::ENCODED if they are not.

Note that the UriFlags::HAS_PASSWORD and UriFlags::HAS_AUTH_PARAMS @flags are ignored by g_uri_split(), since it always returns only the full userinfo; use g_uri_split_with_user() if you want it split up.

§uri_ref

a string containing a relative or absolute URI

§flags

flags for parsing @uri_ref

§Returns

true if @uri_ref parsed successfully, false on error.

§scheme

on return, contains the scheme (converted to lowercase), or None

§userinfo

on return, contains the userinfo, or None

§host

on return, contains the host, or None

§port

on return, contains the port, or -1

§path

on return, contains the path

§query

on return, contains the query, or None

§fragment

on return, contains the fragment, or None Parses @uri_ref (which can be an absolute or relative URI) according to @flags, and returns the pieces. Any component that doesn’t appear in @uri_ref will be returned as None (but note that all URIs always have a path component, though it may be the empty string).

If @flags contains UriFlags::ENCODED, then %-encoded characters in @uri_ref will remain encoded in the output strings. (If not, then all such characters will be decoded.) Note that decoding will only work if the URI components are ASCII or UTF-8, so you will need to use UriFlags::ENCODED if they are not.

Note that the UriFlags::HAS_PASSWORD and UriFlags::HAS_AUTH_PARAMS @flags are ignored by g_uri_split(), since it always returns only the full userinfo; use g_uri_split_with_user() if you want it split up.

§uri_ref

a string containing a relative or absolute URI

§flags

flags for parsing @uri_ref

§Returns

true if @uri_ref parsed successfully, false on error.

§scheme

on return, contains the scheme (converted to lowercase), or None

§userinfo

on return, contains the userinfo, or None

§host

on return, contains the host, or None

§port

on return, contains the port, or -1

§path

on return, contains the path

§query

on return, contains the query, or None

§fragment

on return, contains the fragment, or None

source

pub fn split_network( uri_string: &str, flags: UriFlags, ) -> Result<(Option<GString>, Option<GString>, i32), Error>

Parses @uri_string (which must be an absolute URI) according to @flags, and returns the pieces relevant to connecting to a host. See the documentation for g_uri_split() for more details; this is mostly a wrapper around that function with simpler arguments. However, it will return an error if @uri_string is a relative URI, or does not contain a hostname component.

§uri_string

a string containing an absolute URI

§flags

flags for parsing @uri_string

§Returns

true if @uri_string parsed successfully, false on error.

§scheme

on return, contains the scheme (converted to lowercase), or None

§host

on return, contains the host, or None

§port

on return, contains the port, or -1 Parses @uri_string (which must be an absolute URI) according to @flags, and returns the pieces relevant to connecting to a host. See the documentation for g_uri_split() for more details; this is mostly a wrapper around that function with simpler arguments. However, it will return an error if @uri_string is a relative URI, or does not contain a hostname component.

§uri_string

a string containing an absolute URI

§flags

flags for parsing @uri_string

§Returns

true if @uri_string parsed successfully, false on error.

§scheme

on return, contains the scheme (converted to lowercase), or None

§host

on return, contains the host, or None

§port

on return, contains the port, or -1

source

pub fn split_with_user( uri_ref: &str, flags: UriFlags, ) -> Result<(Option<GString>, Option<GString>, Option<GString>, Option<GString>, Option<GString>, i32, GString, Option<GString>, Option<GString>), Error>

Parses @uri_ref (which can be an absolute or relative URI) according to @flags, and returns the pieces. Any component that doesn’t appear in @uri_ref will be returned as None (but note that all URIs always have a path component, though it may be the empty string).

See g_uri_split(), and the definition of #GUriFlags, for more information on the effect of @flags. Note that @password will only be parsed out if @flags contains UriFlags::HAS_PASSWORD, and @auth_params will only be parsed out if @flags contains UriFlags::HAS_AUTH_PARAMS.

§uri_ref

a string containing a relative or absolute URI

§flags

flags for parsing @uri_ref

§Returns

true if @uri_ref parsed successfully, false on error.

§scheme

on return, contains the scheme (converted to lowercase), or None

§user

on return, contains the user, or None

§password

on return, contains the password, or None

§auth_params

on return, contains the auth_params, or None

§host

on return, contains the host, or None

§port

on return, contains the port, or -1

§path

on return, contains the path

§query

on return, contains the query, or None

§fragment

on return, contains the fragment, or None Parses @uri_ref (which can be an absolute or relative URI) according to @flags, and returns the pieces. Any component that doesn’t appear in @uri_ref will be returned as None (but note that all URIs always have a path component, though it may be the empty string).

See g_uri_split(), and the definition of #GUriFlags, for more information on the effect of @flags. Note that @password will only be parsed out if @flags contains UriFlags::HAS_PASSWORD, and @auth_params will only be parsed out if @flags contains UriFlags::HAS_AUTH_PARAMS.

§uri_ref

a string containing a relative or absolute URI

§flags

flags for parsing @uri_ref

§Returns

true if @uri_ref parsed successfully, false on error.

§scheme

on return, contains the scheme (converted to lowercase), or None

§user

on return, contains the user, or None

§password

on return, contains the password, or None

§auth_params

on return, contains the auth_params, or None

§host

on return, contains the host, or None

§port

on return, contains the port, or -1

§path

on return, contains the path

§query

on return, contains the query, or None

§fragment

on return, contains the fragment, or None

source

pub fn unescape_bytes( escaped_string: &str, illegal_characters: Option<&str>, ) -> Result<Bytes, Error>

Unescapes a segment of an escaped string as binary data.

Note that in contrast to g_uri_unescape_string(), this does allow nul bytes to appear in the output.

If any of the characters in @illegal_characters appears as an escaped character in @escaped_string, then that is an error and None will be returned. This is useful if you want to avoid for instance having a slash being expanded in an escaped path element, which might confuse pathname handling.

§escaped_string

A URI-escaped string

§length

the length (in bytes) of @escaped_string to escape, or -1 if it is nul-terminated.

§illegal_characters

a string of illegal characters not to be allowed, or None.

§Returns

an unescaped version of @escaped_string or None on error (if decoding failed, using UriError::Failed error code). The returned #GBytes should be unreffed when no longer needed. Unescapes a segment of an escaped string as binary data.

Note that in contrast to g_uri_unescape_string(), this does allow nul bytes to appear in the output.

If any of the characters in @illegal_characters appears as an escaped character in @escaped_string, then that is an error and None will be returned. This is useful if you want to avoid for instance having a slash being expanded in an escaped path element, which might confuse pathname handling.

§escaped_string

A URI-escaped string

§length

the length (in bytes) of @escaped_string to escape, or -1 if it is nul-terminated.

§illegal_characters

a string of illegal characters not to be allowed, or None.

§Returns

an unescaped version of @escaped_string or None on error (if decoding failed, using UriError::Failed error code). The returned #GBytes should be unreffed when no longer needed.

source

pub fn unescape_segment( escaped_string: Option<&str>, escaped_string_end: Option<&str>, illegal_characters: Option<&str>, ) -> Option<GString>

Unescapes a segment of an escaped string.

If any of the characters in @illegal_characters or the NUL character appears as an escaped character in @escaped_string, then that is an error and None will be returned. This is useful if you want to avoid for instance having a slash being expanded in an escaped path element, which might confuse pathname handling.

Note: NUL byte is not accepted in the output, in contrast to g_uri_unescape_bytes().

§escaped_string

A string, may be None

§escaped_string_end

Pointer to end of @escaped_string, may be None

§illegal_characters

An optional string of illegal characters not to be allowed, may be None

§Returns

an unescaped version of @escaped_string, or None on error. The returned string should be freed when no longer needed. As a special case if None is given for @escaped_string, this function will return None. Unescapes a segment of an escaped string.

If any of the characters in @illegal_characters or the NUL character appears as an escaped character in @escaped_string, then that is an error and None will be returned. This is useful if you want to avoid for instance having a slash being expanded in an escaped path element, which might confuse pathname handling.

Note: NUL byte is not accepted in the output, in contrast to g_uri_unescape_bytes().

§escaped_string

A string, may be None

§escaped_string_end

Pointer to end of @escaped_string, may be None

§illegal_characters

An optional string of illegal characters not to be allowed, may be None

§Returns

an unescaped version of @escaped_string, or None on error. The returned string should be freed when no longer needed. As a special case if None is given for @escaped_string, this function will return None.

source

pub fn unescape_string( escaped_string: &str, illegal_characters: Option<&str>, ) -> Option<GString>

Unescapes a whole escaped string.

If any of the characters in @illegal_characters or the NUL character appears as an escaped character in @escaped_string, then that is an error and None will be returned. This is useful if you want to avoid for instance having a slash being expanded in an escaped path element, which might confuse pathname handling.

§escaped_string

an escaped string to be unescaped.

§illegal_characters

a string of illegal characters not to be allowed, or None.

§Returns

an unescaped version of @escaped_string. The returned string should be freed when no longer needed. Unescapes a whole escaped string.

If any of the characters in @illegal_characters or the NUL character appears as an escaped character in @escaped_string, then that is an error and None will be returned. This is useful if you want to avoid for instance having a slash being expanded in an escaped path element, which might confuse pathname handling.

§escaped_string

an escaped string to be unescaped.

§illegal_characters

a string of illegal characters not to be allowed, or None.

§Returns

an unescaped version of @escaped_string. The returned string should be freed when no longer needed.

Trait Implementations§

source§

impl Clone for Uri

source§

fn clone(&self) -> Self

Makes a clone of this shared reference.

This increments the strong reference count of the reference. Dropping the reference will decrement it again.

1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Uri

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Uri

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Uri> for Value

source§

fn from(s: Uri) -> Self

Converts to this type from the input type.
source§

impl HasParamSpec for Uri

§

type ParamSpec = ParamSpecBoxed

§

type SetValue = Uri

Preferred value to be used as setter for the associated ParamSpec.
§

type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, Uri>

source§

fn param_spec_builder() -> Self::BuilderFn

source§

impl Hash for Uri

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Uri

source§

fn cmp(&self, other: &Uri) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Uri

source§

fn eq(&self, other: &Uri) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Uri

source§

fn partial_cmp(&self, other: &Uri) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl StaticType for Uri

source§

fn static_type() -> Type

Returns the type identifier of Self.
source§

impl Eq for Uri

source§

impl Send for Uri

source§

impl StructuralPartialEq for Uri

source§

impl Sync for Uri

Auto Trait Implementations§

§

impl Freeze for Uri

§

impl RefUnwindSafe for Uri

§

impl Unpin for Uri

§

impl UnwindSafe for Uri

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(_: *const GList, _: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(_: *const GList, _: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GPtrArray, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize, ) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(_: *const GPtrArray, _: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GSList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize, ) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *const GList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(_: *const GList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(_: *const GList) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *const GSList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(_: *const GSList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(_: *const GSList) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T>

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoClosureReturnValue for T
where T: Into<Value>,

source§

impl<T> Property for T
where T: HasParamSpec,

§

type Value = T

source§

impl<T> PropertyGet for T
where T: HasParamSpec,

§

type Value = T

source§

fn get<R, F>(&self, f: F) -> R
where F: Fn(&<T as PropertyGet>::Value) -> R,

source§

impl<T> StaticTypeExt for T
where T: StaticType,

source§

fn ensure_type()

Ensures that the type has been registered with the type system.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToSendValue for T
where T: Send + ToValue + ?Sized,

source§

fn to_send_value(&self) -> SendValue

Returns a SendValue clone of self.
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T> TransparentType for T

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T> TryFromClosureReturnValue for T
where T: for<'a> FromValue<'a> + StaticType + 'static,

source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<'a, T, C, E> FromValueOptional<'a> for T
where T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,