[][src]Trait gio::NetworkMonitorExt

pub trait NetworkMonitorExt: 'static {
    fn can_reach<P: IsA<SocketConnectable>, Q: IsA<Cancellable>>(
        &self,
        connectable: &P,
        cancellable: Option<&Q>
    ) -> Result<(), Error>;
fn can_reach_async<P: IsA<SocketConnectable>, Q: IsA<Cancellable>, R: FnOnce(Result<(), Error>) + Send + 'static>(
        &self,
        connectable: &P,
        cancellable: Option<&Q>,
        callback: R
    );
fn can_reach_async_future<P: IsA<SocketConnectable> + Clone + 'static>(
        &self,
        connectable: &P
    ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>;
fn get_connectivity(&self) -> NetworkConnectivity;
fn get_network_available(&self) -> bool;
fn connect_network_changed<F: Fn(&Self, bool) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_connectivity_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_network_available_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }

Trait containing all NetworkMonitor methods.

Implementors

NetworkMonitor

Required methods

fn can_reach<P: IsA<SocketConnectable>, Q: IsA<Cancellable>>(
    &self,
    connectable: &P,
    cancellable: Option<&Q>
) -> Result<(), Error>

Attempts to determine whether or not the host pointed to by connectable can be reached, without actually trying to connect to it.

This may return true even when NetworkMonitor:network-available is false, if, for example, self can determine that connectable refers to a host on a local network.

If self believes that an attempt to connect to connectable will succeed, it will return true. Otherwise, it will return false and set error to an appropriate error (such as IOErrorEnum::HostUnreachable).

Note that although this does not attempt to connect to connectable, it may still block for a brief period of time (eg, trying to do multicast DNS on the local network), so if you do not want to block, you should use NetworkMonitor::can_reach_async.

connectable

a SocketConnectable

cancellable

a Cancellable, or None

Returns

true if connectable is reachable, false if not.

fn can_reach_async<P: IsA<SocketConnectable>, Q: IsA<Cancellable>, R: FnOnce(Result<(), Error>) + Send + 'static>(
    &self,
    connectable: &P,
    cancellable: Option<&Q>,
    callback: R
)

Asynchronously attempts to determine whether or not the host pointed to by connectable can be reached, without actually trying to connect to it.

For more details, see NetworkMonitor::can_reach.

When the operation is finished, callback will be called. You can then call NetworkMonitor::can_reach_finish to get the result of the operation.

connectable

a SocketConnectable

cancellable

a Cancellable, or None

callback

a GAsyncReadyCallback to call when the request is satisfied

user_data

the data to pass to callback function

fn can_reach_async_future<P: IsA<SocketConnectable> + Clone + 'static>(
    &self,
    connectable: &P
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

fn get_connectivity(&self) -> NetworkConnectivity

Gets a more detailed networking state than NetworkMonitor::get_network_available.

If NetworkMonitor:network-available is false, then the connectivity state will be NetworkConnectivity::Local.

If NetworkMonitor:network-available is true, then the connectivity state will be NetworkConnectivity::Full (if there is full Internet connectivity), NetworkConnectivity::Limited (if the host has a default route, but appears to be unable to actually reach the full Internet), or NetworkConnectivity::Portal (if the host is trapped behind a "captive portal" that requires some sort of login or acknowledgement before allowing full Internet access).

Note that in the case of NetworkConnectivity::Limited and NetworkConnectivity::Portal, it is possible that some sites are reachable but others are not. In this case, applications can attempt to connect to remote servers, but should gracefully fall back to their "offline" behavior if the connection attempt fails.

Feature: v2_44

Returns

the network connectivity state

fn get_network_available(&self) -> bool

Checks if the network is available. "Available" here means that the system has a default route available for at least one of IPv4 or IPv6. It does not necessarily imply that the public Internet is reachable. See NetworkMonitor:network-available for more details.

Returns

whether the network is available

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

Emitted when the network configuration changes.

network_available

the current value of NetworkMonitor:network-available

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

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

Loading content...

Implementors

impl<O: IsA<NetworkMonitor>> NetworkMonitorExt for O[src]

Loading content...