Trait gio::prelude::ResolverExt

source ·
pub trait ResolverExt: IsA<Resolver> + Sealed + 'static {
Show 20 methods // Provided methods fn timeout(&self) -> u32 { ... } fn lookup_by_address( &self, address: &impl IsA<InetAddress>, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<GString, Error> { ... } fn lookup_by_address_async<P: FnOnce(Result<GString, Error>) + 'static>( &self, address: &impl IsA<InetAddress>, cancellable: Option<&impl IsA<Cancellable>>, callback: P ) { ... } fn lookup_by_address_future( &self, address: &(impl IsA<InetAddress> + Clone + 'static) ) -> Pin<Box_<dyn Future<Output = Result<GString, Error>> + 'static>> { ... } fn lookup_by_name( &self, hostname: &str, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<Vec<InetAddress>, Error> { ... } fn lookup_by_name_async<P: FnOnce(Result<Vec<InetAddress>, Error>) + 'static>( &self, hostname: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P ) { ... } fn lookup_by_name_future( &self, hostname: &str ) -> Pin<Box_<dyn Future<Output = Result<Vec<InetAddress>, Error>> + 'static>> { ... } fn lookup_by_name_with_flags( &self, hostname: &str, flags: ResolverNameLookupFlags, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<Vec<InetAddress>, Error> { ... } fn lookup_by_name_with_flags_async<P: FnOnce(Result<Vec<InetAddress>, Error>) + 'static>( &self, hostname: &str, flags: ResolverNameLookupFlags, cancellable: Option<&impl IsA<Cancellable>>, callback: P ) { ... } fn lookup_by_name_with_flags_future( &self, hostname: &str, flags: ResolverNameLookupFlags ) -> Pin<Box_<dyn Future<Output = Result<Vec<InetAddress>, Error>> + 'static>> { ... } fn lookup_records( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<Vec<Variant>, Error> { ... } fn lookup_records_async<P: FnOnce(Result<Vec<Variant>, Error>) + 'static>( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&impl IsA<Cancellable>>, callback: P ) { ... } fn lookup_records_future( &self, rrname: &str, record_type: ResolverRecordType ) -> Pin<Box_<dyn Future<Output = Result<Vec<Variant>, Error>> + 'static>> { ... } fn lookup_service( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<Vec<SrvTarget>, Error> { ... } fn lookup_service_async<P: FnOnce(Result<Vec<SrvTarget>, Error>) + 'static>( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P ) { ... } fn lookup_service_future( &self, service: &str, protocol: &str, domain: &str ) -> Pin<Box_<dyn Future<Output = Result<Vec<SrvTarget>, Error>> + 'static>> { ... } fn set_default(&self) { ... } fn set_timeout(&self, timeout_ms: u32) { ... } fn connect_reload<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... } fn connect_timeout_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Resolver methods.

Implementors

Resolver

Provided Methods§

source

fn timeout(&self) -> u32

Available on crate feature v2_78 only.

Get the timeout applied to all resolver lookups. See timeout.

Returns

the resolver timeout, in milliseconds, or 0 for no timeout

source

fn lookup_by_address( &self, address: &impl IsA<InetAddress>, cancellable: Option<&impl IsA<Cancellable>> ) -> 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 ResolverError.

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.

source

fn lookup_by_address_async<P: FnOnce(Result<GString, Error>) + 'static>( &self, address: &impl IsA<InetAddress>, cancellable: Option<&impl IsA<Cancellable>>, callback: P )

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

source

fn lookup_by_address_future( &self, address: &(impl IsA<InetAddress> + Clone + 'static) ) -> Pin<Box_<dyn Future<Output = Result<GString, Error>> + 'static>>

source

fn lookup_by_name( &self, hostname: &str, cancellable: Option<&impl IsA<Cancellable>> ) -> 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 ResolverError 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.)

source

fn lookup_by_name_async<P: FnOnce(Result<Vec<InetAddress>, Error>) + 'static>( &self, hostname: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P )

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

source

fn lookup_by_name_future( &self, hostname: &str ) -> Pin<Box_<dyn Future<Output = Result<Vec<InetAddress>, Error>> + 'static>>

source

fn lookup_by_name_with_flags( &self, hostname: &str, flags: ResolverNameLookupFlags, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<Vec<InetAddress>, Error>

Available on crate feature 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.)

source

fn lookup_by_name_with_flags_async<P: FnOnce(Result<Vec<InetAddress>, Error>) + 'static>( &self, hostname: &str, flags: ResolverNameLookupFlags, cancellable: Option<&impl IsA<Cancellable>>, callback: P )

Available on crate feature 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

source

fn lookup_by_name_with_flags_future( &self, hostname: &str, flags: ResolverNameLookupFlags ) -> Pin<Box_<dyn Future<Output = Result<Vec<InetAddress>, Error>> + 'static>>

Available on crate feature v2_60 only.
source

fn lookup_records( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&impl IsA<Cancellable>> ) -> 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 ResolverError 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.)

source

fn lookup_records_async<P: FnOnce(Result<Vec<Variant>, Error>) + 'static>( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&impl IsA<Cancellable>>, callback: P )

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

source

fn lookup_records_future( &self, rrname: &str, record_type: ResolverRecordType ) -> Pin<Box_<dyn Future<Output = Result<Vec<Variant>, Error>> + 'static>>

source

fn lookup_service( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&impl IsA<Cancellable>> ) -> Result<Vec<SrvTarget>, Error>

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 ResolverError 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.)

source

fn lookup_service_async<P: FnOnce(Result<Vec<SrvTarget>, Error>) + 'static>( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P )

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

source

fn lookup_service_future( &self, service: &str, protocol: &str, domain: &str ) -> Pin<Box_<dyn Future<Output = Result<Vec<SrvTarget>, Error>> + 'static>>

source

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.

source

fn set_timeout(&self, timeout_ms: u32)

Available on crate feature v2_78 only.

Set the timeout applied to all resolver lookups. See timeout.

timeout_ms

timeout in milliseconds, or 0 for no timeouts

source

fn connect_reload<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Emitted when the resolver notices that the system resolver configuration has changed.

source

fn connect_timeout_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Available on crate feature v2_78 only.

Object Safety§

This trait is not object safe.

Implementors§