#[repr(transparent)]pub struct Uri { /* private fields */ }
v2_66
only.Implementations§
source§impl Uri
impl Uri
pub fn auth_params(&self) -> Option<GString>
pub fn flags(&self) -> UriFlags
pub fn fragment(&self) -> Option<GString>
pub fn host(&self) -> Option<GString>
pub fn password(&self) -> Option<GString>
pub fn path(&self) -> GString
pub fn port(&self) -> i32
pub fn query(&self) -> Option<GString>
pub fn scheme(&self) -> GString
pub fn user(&self) -> Option<GString>
pub fn userinfo(&self) -> Option<GString>
pub fn parse_relative( &self, uri_ref: &str, flags: UriFlags ) -> Result<Uri, Error>
pub fn to_str(&self) -> GString
pub fn to_string_partial(&self, flags: UriHideFlags) -> GString
pub fn build( flags: UriFlags, scheme: &str, userinfo: Option<&str>, host: Option<&str>, port: i32, path: &str, query: Option<&str>, fragment: Option<&str> ) -> Uri
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
pub fn escape_bytes( unescaped: &[u8], reserved_chars_allowed: Option<&str> ) -> GString
pub fn escape_string( unescaped: &str, reserved_chars_allowed: Option<&str>, allow_utf8: bool ) -> GString
pub fn is_valid(uri_string: &str, flags: UriFlags) -> Result<(), Error>
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
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
pub fn list_extract_uris(uri_list: &str) -> Vec<GString>
sourcepub fn parse(uri_string: &str, flags: UriFlags) -> Result<Uri, Error>
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][relative-absolute-uris], 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 Uri
, or NULL on error.
sourcepub fn parse_scheme(uri: &str) -> Option<GString>
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.
sourcepub fn peek_scheme(uri: &str) -> Option<GString>
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 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.
sourcepub fn resolve_relative(
base_uri_string: Option<&str>,
uri_ref: &str,
flags: UriFlags
) -> Result<GString, Error>
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][relative-absolute-uris], 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.
sourcepub fn split(
uri_ref: &str,
flags: UriFlags
) -> Result<(Option<GString>, Option<GString>, Option<GString>, i32, GString, Option<GString>, Option<GString>), Error>
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][relative-absolute-uris]) 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 split()
,
since it always returns only the full userinfo; use
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
sourcepub fn split_network(
uri_string: &str,
flags: UriFlags
) -> Result<(Option<GString>, Option<GString>, i32), Error>
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][relative-absolute-uris])
according to flags
, and returns the pieces relevant to connecting to a host.
See the documentation for 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
sourcepub 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>
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][relative-absolute-uris]) 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 split()
, and the definition of UriFlags
, 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
sourcepub fn unescape_bytes(
escaped_string: &str,
illegal_characters: Option<&str>
) -> Result<Bytes, Error>
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 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 Bytes
should be unreffed when no longer needed.
sourcepub fn unescape_segment(
escaped_string: Option<&str>,
escaped_string_end: Option<&str>,
illegal_characters: Option<&str>
) -> Option<GString>
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
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
.
sourcepub fn unescape_string(
escaped_string: &str,
illegal_characters: Option<&str>
) -> Option<GString>
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.
Trait Implementations§
source§impl Ord for Uri
impl Ord for Uri
source§impl PartialOrd<Uri> for Uri
impl PartialOrd<Uri> for Uri
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl StaticType for Uri
impl StaticType for Uri
source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for Uri
impl Send for Uri
impl StructuralEq for Uri
impl StructuralPartialEq for Uri
impl Sync for Uri
Auto Trait Implementations§
Blanket Implementations§
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> StaticTypeExt for Twhere
T: StaticType,
impl<T> StaticTypeExt for Twhere T: StaticType,
source§fn ensure_type()
fn ensure_type()
source§impl<T> ToClosureReturnValue for Twhere
T: ToValue,
impl<T> ToClosureReturnValue for Twhere T: ToValue,
fn to_closure_return_value(&self) -> Option<Value>
source§impl<T> ToSendValue for Twhere
T: Send + ToValue + ?Sized,
impl<T> ToSendValue for Twhere T: Send + ToValue + ?Sized,
source§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
SendValue
clone of self
.