Trait gio::prelude::ResolverExt [−][src]
pub trait ResolverExt: 'static {}Show methods
fn lookup_by_address<P: IsA<InetAddress>, Q: IsA<Cancellable>>(
&self,
address: &P,
cancellable: Option<&Q>
) -> Result<GString, Error>; fn lookup_by_address_async<P: IsA<InetAddress>, Q: IsA<Cancellable>, R: FnOnce(Result<GString, Error>) + Send + 'static>(
&self,
address: &P,
cancellable: Option<&Q>,
callback: R
); fn lookup_by_address_async_future<P: IsA<InetAddress> + Clone + 'static>(
&self,
address: &P
) -> Pin<Box_<dyn Future<Output = Result<GString, Error>> + 'static>>; fn lookup_by_name<P: IsA<Cancellable>>(
&self,
hostname: &str,
cancellable: Option<&P>
) -> Result<Vec<InetAddress>, Error>; fn lookup_by_name_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<InetAddress>, Error>) + Send + 'static>(
&self,
hostname: &str,
cancellable: Option<&P>,
callback: Q
); fn lookup_by_name_async_future(
&self,
hostname: &str
) -> Pin<Box_<dyn Future<Output = Result<Vec<InetAddress>, Error>> + 'static>>; fn lookup_by_name_with_flags<P: IsA<Cancellable>>(
&self,
hostname: &str,
flags: ResolverNameLookupFlags,
cancellable: Option<&P>
) -> Result<Vec<InetAddress>, Error>; fn lookup_by_name_with_flags_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<InetAddress>, Error>) + Send + 'static>(
&self,
hostname: &str,
flags: ResolverNameLookupFlags,
cancellable: Option<&P>,
callback: Q
); fn lookup_by_name_with_flags_async_future(
&self,
hostname: &str,
flags: ResolverNameLookupFlags
) -> Pin<Box_<dyn Future<Output = Result<Vec<InetAddress>, Error>> + 'static>>; fn lookup_records<P: IsA<Cancellable>>(
&self,
rrname: &str,
record_type: ResolverRecordType,
cancellable: Option<&P>
) -> Result<Vec<Variant>, Error>; fn lookup_records_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<Variant>, Error>) + Send + 'static>(
&self,
rrname: &str,
record_type: ResolverRecordType,
cancellable: Option<&P>,
callback: Q
); fn lookup_records_async_future(
&self,
rrname: &str,
record_type: ResolverRecordType
) -> Pin<Box_<dyn Future<Output = Result<Vec<Variant>, Error>> + 'static>>; fn lookup_service<P: IsA<Cancellable>>(
&self,
service: &str,
protocol: &str,
domain: &str,
cancellable: Option<&P>
) -> Result<Vec<SrvTarget>, Error>; fn lookup_service_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<SrvTarget>, Error>) + Send + 'static>(
&self,
service: &str,
protocol: &str,
domain: &str,
cancellable: Option<&P>,
callback: Q
); fn lookup_service_async_future(
&self,
service: &str,
protocol: &str,
domain: &str
) -> Pin<Box_<dyn Future<Output = Result<Vec<SrvTarget>, Error>> + 'static>>; fn set_default(&self); fn connect_reload<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
Expand description
Required methods
fn lookup_by_address<P: IsA<InetAddress>, Q: IsA<Cancellable>>(
&self,
address: &P,
cancellable: Option<&Q>
) -> Result<GString, Error>
fn lookup_by_address<P: IsA<InetAddress>, Q: IsA<Cancellable>>(
&self,
address: &P,
cancellable: Option<&Q>
) -> Result<GString, Error>
Synchronously reverse-resolves address
to determine its
associated hostname.
If the DNS resolution fails, error
(if non-None
) will be set to
a value from GResolverError
.
If cancellable
is non-None
, it can be used to cancel the
operation, in which case error
(if non-None
) will be set to
IOErrorEnum::Cancelled
.
address
the address to reverse-resolve
cancellable
a Cancellable
, or None
Returns
a hostname (either ASCII-only, or in ASCII-encoded
form), or None
on error.
fn lookup_by_address_async<P: IsA<InetAddress>, Q: IsA<Cancellable>, R: FnOnce(Result<GString, Error>) + Send + 'static>(
&self,
address: &P,
cancellable: Option<&Q>,
callback: R
)
fn lookup_by_address_async<P: IsA<InetAddress>, Q: IsA<Cancellable>, R: FnOnce(Result<GString, Error>) + Send + 'static>(
&self,
address: &P,
cancellable: Option<&Q>,
callback: R
)
Begins asynchronously reverse-resolving address
to determine its
associated hostname, and eventually calls callback
, which must
call g_resolver_lookup_by_address_finish()
to get the final result.
address
the address to reverse-resolve
cancellable
a Cancellable
, or None
callback
callback to call after resolution completes
fn lookup_by_address_async_future<P: IsA<InetAddress> + Clone + 'static>(
&self,
address: &P
) -> Pin<Box_<dyn Future<Output = Result<GString, Error>> + 'static>>
fn lookup_by_name<P: IsA<Cancellable>>(
&self,
hostname: &str,
cancellable: Option<&P>
) -> Result<Vec<InetAddress>, Error>
fn lookup_by_name<P: IsA<Cancellable>>(
&self,
hostname: &str,
cancellable: Option<&P>
) -> Result<Vec<InetAddress>, Error>
Synchronously resolves hostname
to determine its associated IP
address(es). hostname
may be an ASCII-only or UTF-8 hostname, or
the textual form of an IP address (in which case this just becomes
a wrapper around InetAddress::from_string()
).
On success, lookup_by_name()
will return a non-empty GList
of
InetAddress
, sorted in order of preference and guaranteed to not
contain duplicates. That is, if using the result to connect to
hostname
, you should attempt to connect to the first address
first, then the second if the first fails, etc. If you are using
the result to listen on a socket, it is appropriate to add each
result using e.g. SocketListenerExt::add_address()
.
If the DNS resolution fails, error
(if non-None
) will be set to a
value from GResolverError
and None
will be returned.
If cancellable
is non-None
, it can be used to cancel the
operation, in which case error
(if non-None
) will be set to
IOErrorEnum::Cancelled
.
If you are planning to connect to a socket on the resolved IP
address, it may be easier to create a NetworkAddress
and use its
SocketConnectable
interface.
hostname
the hostname to look up
cancellable
a Cancellable
, or None
Returns
a non-empty GList
of InetAddress
, or None
on error. You
must unref each of the addresses and free the list when you are
done with it. (You can use g_resolver_free_addresses()
to do this.)
fn lookup_by_name_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<InetAddress>, Error>) + Send + 'static>(
&self,
hostname: &str,
cancellable: Option<&P>,
callback: Q
)
fn lookup_by_name_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<InetAddress>, Error>) + Send + 'static>(
&self,
hostname: &str,
cancellable: Option<&P>,
callback: Q
)
Begins asynchronously resolving hostname
to determine its
associated IP address(es), and eventually calls callback
, which
must call g_resolver_lookup_by_name_finish()
to get the result.
See lookup_by_name()
for more details.
hostname
the hostname to look up the address of
cancellable
a Cancellable
, or None
callback
callback to call after resolution completes
fn lookup_by_name_async_future(
&self,
hostname: &str
) -> Pin<Box_<dyn Future<Output = Result<Vec<InetAddress>, Error>> + 'static>>
fn lookup_by_name_with_flags<P: IsA<Cancellable>>(
&self,
hostname: &str,
flags: ResolverNameLookupFlags,
cancellable: Option<&P>
) -> Result<Vec<InetAddress>, Error>
fn lookup_by_name_with_flags<P: IsA<Cancellable>>(
&self,
hostname: &str,
flags: ResolverNameLookupFlags,
cancellable: Option<&P>
) -> Result<Vec<InetAddress>, Error>
v2_60
only.This differs from lookup_by_name()
in that you can modify
the lookup behavior with flags
. For example this can be used to limit
results with ResolverNameLookupFlags::IPV4_ONLY
.
hostname
the hostname to look up
flags
extra ResolverNameLookupFlags
for the lookup
cancellable
a Cancellable
, or None
Returns
a non-empty GList
of InetAddress
, or None
on error. You
must unref each of the addresses and free the list when you are
done with it. (You can use g_resolver_free_addresses()
to do this.)
fn lookup_by_name_with_flags_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<InetAddress>, Error>) + Send + 'static>(
&self,
hostname: &str,
flags: ResolverNameLookupFlags,
cancellable: Option<&P>,
callback: Q
)
fn lookup_by_name_with_flags_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<InetAddress>, Error>) + Send + 'static>(
&self,
hostname: &str,
flags: ResolverNameLookupFlags,
cancellable: Option<&P>,
callback: Q
)
v2_60
only.Begins asynchronously resolving hostname
to determine its
associated IP address(es), and eventually calls callback
, which
must call g_resolver_lookup_by_name_with_flags_finish()
to get the result.
See lookup_by_name()
for more details.
hostname
the hostname to look up the address of
flags
extra ResolverNameLookupFlags
for the lookup
cancellable
a Cancellable
, or None
callback
callback to call after resolution completes
fn lookup_by_name_with_flags_async_future(
&self,
hostname: &str,
flags: ResolverNameLookupFlags
) -> Pin<Box_<dyn Future<Output = Result<Vec<InetAddress>, Error>> + 'static>>
fn lookup_by_name_with_flags_async_future(
&self,
hostname: &str,
flags: ResolverNameLookupFlags
) -> Pin<Box_<dyn Future<Output = Result<Vec<InetAddress>, Error>> + 'static>>
v2_60
only.fn lookup_records<P: IsA<Cancellable>>(
&self,
rrname: &str,
record_type: ResolverRecordType,
cancellable: Option<&P>
) -> Result<Vec<Variant>, Error>
fn lookup_records<P: IsA<Cancellable>>(
&self,
rrname: &str,
record_type: ResolverRecordType,
cancellable: Option<&P>
) -> Result<Vec<Variant>, Error>
Synchronously performs a DNS record lookup for the given rrname
and returns
a list of records as glib::Variant
tuples. See ResolverRecordType
for
information on what the records contain for each record_type
.
If the DNS resolution fails, error
(if non-None
) will be set to
a value from GResolverError
and None
will be returned.
If cancellable
is non-None
, it can be used to cancel the
operation, in which case error
(if non-None
) will be set to
IOErrorEnum::Cancelled
.
rrname
the DNS name to look up the record for
record_type
the type of DNS record to look up
cancellable
a Cancellable
, or None
Returns
a non-empty GList
of
glib::Variant
, or None
on error. You must free each of the records and the list
when you are done with it. (You can use g_list_free_full()
with
g_variant_unref()
to do this.)
fn lookup_records_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<Variant>, Error>) + Send + 'static>(
&self,
rrname: &str,
record_type: ResolverRecordType,
cancellable: Option<&P>,
callback: Q
)
fn lookup_records_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<Variant>, Error>) + Send + 'static>(
&self,
rrname: &str,
record_type: ResolverRecordType,
cancellable: Option<&P>,
callback: Q
)
Begins asynchronously performing a DNS lookup for the given
rrname
, and eventually calls callback
, which must call
g_resolver_lookup_records_finish()
to get the final result. See
lookup_records()
for more details.
rrname
the DNS name to look up the record for
record_type
the type of DNS record to look up
cancellable
a Cancellable
, or None
callback
callback to call after resolution completes
fn lookup_records_async_future(
&self,
rrname: &str,
record_type: ResolverRecordType
) -> Pin<Box_<dyn Future<Output = Result<Vec<Variant>, Error>> + 'static>>
Synchronously performs a DNS SRV lookup for the given service
and
protocol
in the given domain
and returns an array of SrvTarget
.
domain
may be an ASCII-only or UTF-8 hostname. Note also that the
service
and protocol
arguments do not include the leading underscore
that appears in the actual DNS entry.
On success, lookup_service()
will return a non-empty GList
of
SrvTarget
, sorted in order of preference. (That is, you should
attempt to connect to the first target first, then the second if
the first fails, etc.)
If the DNS resolution fails, error
(if non-None
) will be set to
a value from GResolverError
and None
will be returned.
If cancellable
is non-None
, it can be used to cancel the
operation, in which case error
(if non-None
) will be set to
IOErrorEnum::Cancelled
.
If you are planning to connect to the service, it is usually easier
to create a NetworkService
and use its SocketConnectable
interface.
service
the service type to look up (eg, “ldap”)
protocol
the networking protocol to use for service
(eg, “tcp”)
domain
the DNS domain to look up the service in
cancellable
a Cancellable
, or None
Returns
a non-empty GList
of
SrvTarget
, or None
on error. You must free each of the targets and the
list when you are done with it. (You can use g_resolver_free_targets()
to do
this.)
Begins asynchronously performing a DNS SRV lookup for the given
service
and protocol
in the given domain
, and eventually calls
callback
, which must call g_resolver_lookup_service_finish()
to
get the final result. See lookup_service()
for more
details.
service
the service type to look up (eg, “ldap”)
protocol
the networking protocol to use for service
(eg, “tcp”)
domain
the DNS domain to look up the service in
cancellable
a Cancellable
, or None
callback
callback to call after resolution completes
fn lookup_service_async_future(
&self,
service: &str,
protocol: &str,
domain: &str
) -> Pin<Box_<dyn Future<Output = Result<Vec<SrvTarget>, Error>> + 'static>>
fn set_default(&self)
fn set_default(&self)
Sets self
to be the application’s default resolver (reffing
self
, and unreffing the previous default resolver, if any).
Future calls to Resolver::default()
will return this resolver.
This can be used if an application wants to perform any sort of DNS
caching or “pinning”; it can implement its own Resolver
that
calls the original default resolver for DNS operations, and
implements its own cache policies on top of that, and then set
itself as the default resolver for all later code to use.
fn connect_reload<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_reload<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Emitted when the resolver notices that the system resolver configuration has changed.