Trait gio::prelude::NetworkMonitorExt [−][src]
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 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
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
cancellable
a Cancellable
, or None
Returns
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<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 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
cancellable
a Cancellable
, or None
callback
a GAsyncReadyCallback
to call when the
request is satisfied
fn can_reach_async_future<P: IsA<SocketConnectable> + Clone + 'static>(
&self,
connectable: &P
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
fn connectivity(&self) -> NetworkConnectivity
fn connectivity(&self) -> NetworkConnectivity
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
fn is_network_available(&self) -> bool
fn is_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 property::NetworkMonitor::network-available
for more details.
Returns
whether the network is available
fn is_network_metered(&self) -> bool
fn is_network_metered(&self) -> bool
Checks if the network is metered.
See property::NetworkMonitor::network-metered
for more details.
Returns
whether the connection is metered
fn connect_network_changed<F: Fn(&Self, bool) + 'static>(
&self,
f: F
) -> SignalHandlerId
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 property::NetworkMonitor::network-available
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