Expand description
Cross-platform detection of whether the current network connection is metered.
A metered connection is one where the operating system (or the user) has indicated that data usage may be limited or billed, e.g. cellular data, a mobile hotspot or a capped plan. Applications can use this to avoid large background transfers on such connections.
| Platform | Source |
|---|---|
| Windows | the Network List Manager COM API (INetworkCostManager::GetCost) |
| Linux | the Metered property of org.freedesktop.NetworkManager on the D-Bus system bus |
macOS is not supported yet.
§Usage
if is_metered_network::check()? {
println!("on a metered connection");
}For the underlying cost instead of a plain bool (e.g. to distinguish a known-unmetered
connection from an unknown one), use connection_cost:
println!("{}", is_metered_network::connection_cost()?);Enums§
- Connection
Cost - The cost/metered status of a network connection.
Functions§
- check
- Returns
trueif the current network connection is metered. - connection_
cost - Returns the cost/metered status of the current primary network connection.