ConnectionExt

Trait ConnectionExt 

Source
pub trait ConnectionExt: IsA<Connection> + 'static {
Show 63 methods // Provided methods fn add_setting(&self, setting: impl IsA<Setting>) { ... } fn clear_secrets(&self) { ... } fn clear_secrets_with_flags( &self, func: Option<&mut dyn FnMut(&Setting, &str, &SettingSecretFlags) -> bool>, ) { ... } fn clear_settings(&self) { ... } fn compare( &self, b: &impl IsA<Connection>, flags: SettingCompareFlags, ) -> bool { ... } fn dump(&self) { ... } fn connection_type(&self) -> GString { ... } fn id(&self) -> GString { ... } fn interface_name(&self) -> GString { ... } fn path(&self) -> GString { ... } fn setting(&self, setting_type: Type) -> Setting { ... } fn setting_802_1x(&self) -> Setting8021x { ... } fn setting_adsl(&self) -> SettingAdsl { ... } fn setting_bluetooth(&self) -> SettingBluetooth { ... } fn setting_bond(&self) -> SettingBond { ... } fn setting_bridge(&self) -> SettingBridge { ... } fn setting_bridge_port(&self) -> SettingBridgePort { ... } fn setting_by_name(&self, name: &str) -> Setting { ... } fn setting_cdma(&self) -> SettingCdma { ... } fn setting_connection(&self) -> SettingConnection { ... } fn setting_dcb(&self) -> SettingDcb { ... } fn setting_dummy(&self) -> SettingDummy { ... } fn setting_generic(&self) -> SettingGeneric { ... } fn setting_gsm(&self) -> SettingGsm { ... } fn setting_infiniband(&self) -> SettingInfiniband { ... } fn setting_ip4_config(&self) -> SettingIP4Config { ... } fn setting_ip6_config(&self) -> SettingIP6Config { ... } fn setting_ip_tunnel(&self) -> SettingIPTunnel { ... } fn setting_macsec(&self) -> SettingMacsec { ... } fn setting_macvlan(&self) -> SettingMacvlan { ... } fn setting_olpc_mesh(&self) -> SettingOlpcMesh { ... } fn setting_ovs_bridge(&self) -> SettingOvsBridge { ... } fn setting_ovs_patch(&self) -> SettingOvsPatch { ... } fn setting_ovs_port(&self) -> SettingOvsPort { ... } fn setting_ppp(&self) -> SettingPpp { ... } fn setting_pppoe(&self) -> SettingPppoe { ... } fn setting_proxy(&self) -> SettingProxy { ... } fn setting_serial(&self) -> SettingSerial { ... } fn setting_tc_config(&self) -> SettingTCConfig { ... } fn setting_team(&self) -> SettingTeam { ... } fn setting_team_port(&self) -> SettingTeamPort { ... } fn setting_tun(&self) -> SettingTun { ... } fn setting_vlan(&self) -> SettingVlan { ... } fn setting_vpn(&self) -> SettingVpn { ... } fn setting_vxlan(&self) -> SettingVxlan { ... } fn setting_wimax(&self) -> SettingWimax { ... } fn setting_wired(&self) -> SettingWired { ... } fn setting_wireless(&self) -> SettingWireless { ... } fn setting_wireless_security(&self) -> SettingWirelessSecurity { ... } fn settings(&self) -> Vec<Setting> { ... } fn uuid(&self) -> GString { ... } fn virtual_device_description(&self) -> GString { ... } fn is_type(&self, type_: &str) -> bool { ... } fn is_virtual(&self) -> bool { ... } fn need_secrets(&self) -> (Option<GString>, Vec<GString>) { ... } fn remove_setting(&self, setting_type: Type) { ... } fn replace_settings_from_connection( &self, new_connection: &impl IsA<Connection>, ) { ... } fn set_path(&self, path: &str) { ... } fn verify(&self) -> Result<(), Error> { ... } fn verify_secrets(&self) -> Result<(), Error> { ... } fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... } fn connect_secrets_cleared<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_secrets_updated<F: Fn(&Self, &str) + 'static>( &self, f: F, ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Connection methods.

§Implementors

Connection, RemoteConnection, SimpleConnection

Provided Methods§

Source

fn add_setting(&self, setting: impl IsA<Setting>)

Adds a #NMSetting to the connection, replacing any previous #NMSetting of the same name which has previously been added to the #NMConnection. The connection takes ownership of the #NMSetting object and does not increase the setting object’s reference count.

§setting

the #NMSetting to add to the connection object

Source

fn clear_secrets(&self)

Clears and frees any secrets that may be stored in the connection, to avoid keeping secret data in memory when not needed.

Source

fn clear_secrets_with_flags( &self, func: Option<&mut dyn FnMut(&Setting, &str, &SettingSecretFlags) -> bool>, )

Clears and frees secrets determined by @func.

§func

function to be called to determine whether a specific secret should be cleared or not. If None, all secrets are cleared.

Source

fn clear_settings(&self)

Deletes all of @self’s settings.

Source

fn compare(&self, b: &impl IsA<Connection>, flags: SettingCompareFlags) -> bool

Source

fn dump(&self)

Print the connection (including secrets!) to stdout. For debugging purposes ONLY, should NOT be used for serialization of the setting, or machine-parsed in any way. The output format is not guaranteed to be stable and may change at any time.

Source

fn connection_type(&self) -> GString

A shortcut to return the type from the connection’s #NMSettingConnection.

§Returns

the type from the connection’s ‘connection’ setting

Source

fn id(&self) -> GString

A shortcut to return the ID from the connection’s #NMSettingConnection.

§Returns

the ID from the connection’s ‘connection’ setting

Examples found in repository?
examples/get_password.rs (line 11)
4fn get_password(client: &Client) {
5    let connections = client.connections();
6    let Some(remote_connection) = connections.first() else {
7        return;
8    };
9    println!(
10        "Password for connection {} is {}",
11        remote_connection.id(),
12        remote_connection.setting_wireless_security().psk()
13    )
14}
Source

fn interface_name(&self) -> GString

Returns the interface name as stored in NMSettingConnection:interface_name. If the connection contains no NMSettingConnection, it will return None.

For hardware devices and software devices created outside of NetworkManager, this name is used to match the device. for software devices created by NetworkManager, this is the name of the created interface.

§Returns

Name of the kernel interface or None

Source

fn path(&self) -> GString

Returns the connection’s D-Bus path.

§Returns

the D-Bus path of the connection, previously set by a call to nm_connection_set_path().

Source

fn setting(&self, setting_type: Type) -> Setting

Gets the #NMSetting with the given #GType, if one has been previously added to the #NMConnection.

§setting_type

the #GType of the setting object to return

§Returns

the #NMSetting, or None if no setting of that type was previously added to the #NMConnection

Source

fn setting_802_1x(&self) -> Setting8021x

A shortcut to return any #NMSetting8021x the connection might contain.

§Returns

an #NMSetting8021x if the connection contains one, otherwise None

Source

fn setting_adsl(&self) -> SettingAdsl

A shortcut to return any #NMSettingAdsl the connection might contain.

§Returns

an #NMSettingAdsl if the connection contains one, otherwise None

Source

fn setting_bluetooth(&self) -> SettingBluetooth

A shortcut to return any #NMSettingBluetooth the connection might contain.

§Returns

an #NMSettingBluetooth if the connection contains one, otherwise None

Source

fn setting_bond(&self) -> SettingBond

A shortcut to return any #NMSettingBond the connection might contain.

§Returns

an #NMSettingBond if the connection contains one, otherwise None

Source

fn setting_bridge(&self) -> SettingBridge

A shortcut to return any #NMSettingBridge the connection might contain.

§Returns

an #NMSettingBridge if the connection contains one, otherwise None

Source

fn setting_bridge_port(&self) -> SettingBridgePort

A shortcut to return any #NMSettingBridgePort the connection might contain.

§Returns

an #NMSettingBridgePort if the connection contains one, otherwise None

Source

fn setting_by_name(&self, name: &str) -> Setting

Gets the #NMSetting with the given name, if one has been previously added the #NMConnection.

§name

a setting name

§Returns

the #NMSetting, or None if no setting with that name was previously added to the #NMConnection

Source

fn setting_cdma(&self) -> SettingCdma

A shortcut to return any #NMSettingCdma the connection might contain.

§Returns

an #NMSettingCdma if the connection contains one, otherwise None

Source

fn setting_connection(&self) -> SettingConnection

A shortcut to return any #NMSettingConnection the connection might contain.

§Returns

an #NMSettingConnection if the connection contains one, otherwise None

Source

fn setting_dcb(&self) -> SettingDcb

A shortcut to return any #NMSettingDcb the connection might contain.

§Returns

an #NMSettingDcb if the connection contains one, otherwise NULL

Source

fn setting_dummy(&self) -> SettingDummy

Available on crate feature v1_8 only.

A shortcut to return any #NMSettingDummy the connection might contain.

§Returns

an #NMSettingDummy if the connection contains one, otherwise None

Source

fn setting_generic(&self) -> SettingGeneric

A shortcut to return any #NMSettingGeneric the connection might contain.

§Returns

an #NMSettingGeneric if the connection contains one, otherwise NULL

Source

fn setting_gsm(&self) -> SettingGsm

A shortcut to return any #NMSettingGsm the connection might contain.

§Returns

an #NMSettingGsm if the connection contains one, otherwise None

Source

fn setting_infiniband(&self) -> SettingInfiniband

A shortcut to return any #NMSettingInfiniband the connection might contain.

§Returns

an #NMSettingInfiniband if the connection contains one, otherwise None

Source

fn setting_ip4_config(&self) -> SettingIP4Config

A shortcut to return any #NMSettingIP4Config the connection might contain.

Note that it returns the value as type #NMSettingIPConfig, since the vast majority of IPv4-setting-related methods are on that type, not #NMSettingIP4Config.

§Returns

an #NMSettingIP4Config if the connection contains one, otherwise None

Source

fn setting_ip6_config(&self) -> SettingIP6Config

A shortcut to return any #NMSettingIP6Config the connection might contain.

Note that it returns the value as type #NMSettingIPConfig, since the vast majority of IPv6-setting-related methods are on that type, not #NMSettingIP6Config.

§Returns

an #NMSettingIP6Config if the connection contains one, otherwise None

Source

fn setting_ip_tunnel(&self) -> SettingIPTunnel

Available on crate feature v1_2 only.

A shortcut to return any #NMSettingIPTunnel the connection might contain.

§Returns

an #NMSettingIPTunnel if the connection contains one, otherwise None

Source

fn setting_macsec(&self) -> SettingMacsec

Available on crate feature v1_6 only.

A shortcut to return any #NMSettingMacsec the connection might contain.

§Returns

an #NMSettingMacsec if the connection contains one, otherwise None

Source

fn setting_macvlan(&self) -> SettingMacvlan

Available on crate feature v1_2 only.

A shortcut to return any #NMSettingMacvlan the connection might contain.

§Returns

an #NMSettingMacvlan if the connection contains one, otherwise None

Source

fn setting_olpc_mesh(&self) -> SettingOlpcMesh

A shortcut to return any #NMSettingOlpcMesh the connection might contain.

§Returns

an #NMSettingOlpcMesh if the connection contains one, otherwise None

Source

fn setting_ovs_bridge(&self) -> SettingOvsBridge

Available on crate feature v1_14 only.

A shortcut to return any #NMSettingOvsBridge the connection might contain.

§Returns

an #NMSettingOvsBridge if the connection contains one, otherwise None

Source

fn setting_ovs_patch(&self) -> SettingOvsPatch

Available on crate feature v1_14 only.

A shortcut to return any #NMSettingOvsPatch the connection might contain.

§Returns

an #NMSettingOvsPatch if the connection contains one, otherwise None

Source

fn setting_ovs_port(&self) -> SettingOvsPort

Available on crate feature v1_14 only.

A shortcut to return any #NMSettingOvsPort the connection might contain.

§Returns

an #NMSettingOvsPort if the connection contains one, otherwise None

Source

fn setting_ppp(&self) -> SettingPpp

A shortcut to return any #NMSettingPpp the connection might contain.

§Returns

an #NMSettingPpp if the connection contains one, otherwise None

Source

fn setting_pppoe(&self) -> SettingPppoe

A shortcut to return any #NMSettingPppoe the connection might contain.

§Returns

an #NMSettingPppoe if the connection contains one, otherwise None

Source

fn setting_proxy(&self) -> SettingProxy

Available on crate feature v1_6 only.

A shortcut to return any #NMSettingProxy the connection might contain.

§Returns

an #NMSettingProxy if the connection contains one, otherwise None

Source

fn setting_serial(&self) -> SettingSerial

A shortcut to return any #NMSettingSerial the connection might contain.

§Returns

an #NMSettingSerial if the connection contains one, otherwise None

Source

fn setting_tc_config(&self) -> SettingTCConfig

Available on crate feature v1_12 only.

A shortcut to return any #NMSettingTCConfig the connection might contain.

§Returns

an #NMSettingTCConfig if the connection contains one, otherwise None

Source

fn setting_team(&self) -> SettingTeam

A shortcut to return any #NMSettingTeam the connection might contain.

§Returns

an #NMSettingTeam if the connection contains one, otherwise None

Source

fn setting_team_port(&self) -> SettingTeamPort

A shortcut to return any #NMSettingTeamPort the connection might contain.

§Returns

an #NMSettingTeamPort if the connection contains one, otherwise None

Source

fn setting_tun(&self) -> SettingTun

Available on crate feature v1_14 only.

A shortcut to return any #NMSettingTun the connection might contain.

§Returns

an #NMSettingTun if the connection contains one, otherwise None

Source

fn setting_vlan(&self) -> SettingVlan

A shortcut to return any #NMSettingVlan the connection might contain.

§Returns

an #NMSettingVlan if the connection contains one, otherwise None

Source

fn setting_vpn(&self) -> SettingVpn

A shortcut to return any #NMSettingVpn the connection might contain.

§Returns

an #NMSettingVpn if the connection contains one, otherwise None

Source

fn setting_vxlan(&self) -> SettingVxlan

Available on crate feature v1_2 only.

A shortcut to return any #NMSettingVxlan the connection might contain.

§Returns

an #NMSettingVxlan if the connection contains one, otherwise None

Source

fn setting_wimax(&self) -> SettingWimax

A shortcut to return any #NMSettingWimax the connection might contain.

§Returns

an #NMSettingWimax if the connection contains one, otherwise None

Source

fn setting_wired(&self) -> SettingWired

A shortcut to return any #NMSettingWired the connection might contain.

§Returns

an #NMSettingWired if the connection contains one, otherwise None

Source

fn setting_wireless(&self) -> SettingWireless

A shortcut to return any #NMSettingWireless the connection might contain.

§Returns

an #NMSettingWireless if the connection contains one, otherwise None

Source

fn setting_wireless_security(&self) -> SettingWirelessSecurity

A shortcut to return any #NMSettingWirelessSecurity the connection might contain.

§Returns

an #NMSettingWirelessSecurity if the connection contains one, otherwise None

Examples found in repository?
examples/get_password.rs (line 12)
4fn get_password(client: &Client) {
5    let connections = client.connections();
6    let Some(remote_connection) = connections.first() else {
7        return;
8    };
9    println!(
10        "Password for connection {} is {}",
11        remote_connection.id(),
12        remote_connection.setting_wireless_security().psk()
13    )
14}
Source

fn settings(&self) -> Vec<Setting>

Available on crate feature v1_10 only.

Retrieves the settings in @self.

The returned array is None-terminated.

§Returns

a None-terminated array containing every setting of @self. If the connection has no settings, None is returned.

Source

fn uuid(&self) -> GString

A shortcut to return the UUID from the connection’s #NMSettingConnection.

§Returns

the UUID from the connection’s ‘connection’ setting

Source

fn virtual_device_description(&self) -> GString

Returns the name that nm_device_disambiguate_names() would return for the virtual device that would be created for @self. Eg, “VLAN (eth1.1)”.

§Returns

the name of @self’s device, or None if @self is not a virtual connection type

Source

fn is_type(&self, type_: &str) -> bool

A convenience function to check if the given @self is a particular type (ie wired, Wi-Fi, ppp, etc). Checks the #NMSettingConnection:type property of the connection and matches that against @type_.

§type_

a setting name to check the connection’s type against (like SETTING_WIRELESS_SETTING_NAME or SETTING_WIRED_SETTING_NAME)

§Returns

true if the connection is of the given @type_, false if not

Source

fn is_virtual(&self) -> bool

Checks if @self refers to a virtual device (and thus can potentially be activated even if the device it refers to doesn’t exist).

§Returns

whether @self refers to a virtual device

Source

fn need_secrets(&self) -> (Option<GString>, Vec<GString>)

Returns the name of the first setting object in the connection which would need secrets to make a successful connection. The returned hints are only intended as a guide to what secrets may be required, because in some circumstances, there is no way to conclusively determine exactly which secrets are needed.

§Returns

the setting name of the #NMSetting object which has invalid or missing secrets

§hints

the address of a pointer to a #GPtrArray, initialized to None, which on return points to an allocated #GPtrArray containing the property names of secrets of the #NMSetting which may be required; the caller owns the array and must free the array itself with g_ptr_array_free(), but not free its elements

Source

fn remove_setting(&self, setting_type: Type)

Removes the #NMSetting with the given #GType from the #NMConnection. This operation dereferences the #NMSetting object.

§setting_type

the #GType of the setting object to remove

Source

fn replace_settings_from_connection( &self, new_connection: &impl IsA<Connection>, )

Deep-copies the settings of @new_connection and replaces the settings of @self with the copied settings.

§new_connection

a #NMConnection to replace the settings of @self with

Source

fn set_path(&self, path: &str)

Sets the D-Bus path of the connection. This property is not serialized, and is only for the reference of the caller. Sets the #NMConnection:path property.

§path

the D-Bus path of the connection as given by the settings service which provides the connection

Source

fn verify(&self) -> Result<(), Error>

Validates the connection and all its settings. Each setting’s properties have allowed values, and some values are dependent on other values. For example, if a Wi-Fi connection is security enabled, the #NMSettingWireless setting object’s ‘security’ property must contain the setting name of the #NMSettingWirelessSecurity object, which must also be present in the connection for the connection to be valid. As another example, the #NMSettingWired object’s ‘mac-address’ property must be a validly formatted MAC address. The returned #GError contains information about which setting and which property failed validation, and how it failed validation.

§Returns

true if the connection is valid, false if it is not

Source

fn verify_secrets(&self) -> Result<(), Error>

Available on crate feature v1_2 only.

Verifies the secrets in the connection.

§Returns

true if the secrets are valid, false if they are not

Source

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

The ::changed signal is emitted when any property (including secrets) of any setting of the connection is modified, or when settings are added or removed.

Source

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

The ::secrets-cleared signal is emitted when the secrets of a connection are cleared.

Source

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

The ::secrets-updated signal is emitted when the secrets of a setting have been changed.

§setting_name

the setting name of the #NMSetting for which secrets were updated

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§