pub trait NetworkMonitorExt: 'static {
    fn can_reach(
        &self,
        connectable: &impl IsA<SocketConnectable>,
        cancellable: Option<&impl IsA<Cancellable>>
    ) -> Result<(), Error>; fn can_reach_async<P: FnOnce(Result<(), Error>) + 'static>(
        &self,
        connectable: &impl IsA<SocketConnectable>,
        cancellable: Option<&impl IsA<Cancellable>>,
        callback: P
    ); fn can_reach_future(
        &self,
        connectable: &impl IsA<SocketConnectable> + Clone + 'static
    ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>; fn connectivity(&self) -> NetworkConnectivity; fn is_network_available(&self) -> bool; fn is_network_metered(&self) -> bool; fn connect_network_changed<F: Fn(&Self, bool) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_connectivity_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_network_available_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_network_metered_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }
Expand description

Trait containing all NetworkMonitor methods.

Implementors

NetworkMonitor

Required Methods

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 property::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 can_reach_async().

connectable

a SocketConnectable

cancellable

a Cancellable, or None

Returns

true if connectable is reachable, false if not.

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 can_reach().

When the operation is finished, callback will be called. You can then call g_network_monitor_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

Gets a more detailed networking state than is_network_available().

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

If property::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.

Returns

the network connectivity state

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 property::NetworkMonitor::network-available for more details.

Returns

whether the network is available

Checks if the network is metered. See property::NetworkMonitor::network-metered for more details.

Returns

whether the connection is metered

Emitted when the network configuration changes.

network_available

the current value of property::NetworkMonitor::network-available

Implementors