Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

GLib type: GObject with reference counted clone semantics.

Implementations§

Source§

impl Client

Source

pub fn new(cancellable: Option<&impl IsA<Cancellable>>) -> Result<Client, Error>

Creates a new #NMClient synchronously.

Note that this will block until a NMClient instance is fully initialized. This does nothing beside calling g_initable_new(). You are free to call g_initable_new() or g_object_new()/g_initable_init() directly for more control, to set GObject properties or get access to the NMClient instance while it is still initializing.

Using the synchronous initialization creates an #NMClient instance that uses an internal #GMainContext. This context is invisible to the user. This introduces an additional overhead that is payed not only during object initialization, but for the entire lifetime of this object. Also, due to this internal #GMainContext, the events are no longer in sync with other messages from #GDBusConnection (but all events of the NMClient will themselves still be ordered). For a serious program, you should therefore avoid these problems by using g_async_initable_init_async() or nm_client_new_async() instead. The sync initialization is still useful for simple scripts or interactive testing for example via pygobject.

Creating an #NMClient instance can only fail for two reasons. First, if you didn’t provide a CLIENT_DBUS_CONNECTION and the call to g_bus_get() fails. You can avoid that by using g_initable_new() directly and set a D-Bus connection. Second, if you cancelled the creation. If you do that, then note that after the failure there might still be idle actions pending which keep nm_client_get_main_context() alive. That means, in that case you must continue iterating the context to avoid leaks. See nm_client_get_context_busy_watcher().

Creating an #NMClient instance when NetworkManager is not running does not cause a failure.

§cancellable

a #GCancellable, or None

§Returns

a new #NMClient or NULL on an error

Source

pub fn builder() -> ClientBuilder

Creates a new builder-pattern struct instance to construct Client objects.

This method returns an instance of ClientBuilder which can be used to create Client objects.

Source

pub fn activate_connection_async<P: FnOnce(Result<ActiveConnection, Error>) + 'static>( &self, connection: Option<&impl IsA<Connection>>, device: Option<&impl IsA<Device>>, specific_object: Option<&str>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Asynchronously starts a connection to a particular network using the configuration settings from @connection and the network device @device. Certain connection types also take a “specific object” which is the object path of a connection- specific object, like an #NMAccessPoint for Wi-Fi connections, or an #NMWimaxNsp for WiMAX connections, to which you wish to connect. If the specific object is not given, NetworkManager can, in some cases, automatically determine which network to connect to given the settings in @connection.

If @connection is not given for a device-based activation, NetworkManager picks the best available connection for the device and activates it.

Note that the callback is invoked when NetworkManager has started activating the new connection, not when it finishes. You can use the returned #NMActiveConnection object (in particular, #NMActiveConnection:state) to track the activation to its completion.

§connection

an #NMConnection

§device

the #NMDevice

§specific_object

the object path of a connection-type-specific object this activation should use. This parameter is currently ignored for wired and mobile broadband connections, and the value of None should be used (ie, no specific object). For Wi-Fi or WiMAX connections, pass the object path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can get using nm_object_get_path(), and which will be used to complete the details of the newly added connection.

§cancellable

a #GCancellable, or None

§callback

callback to be called when the activation has started

Source

pub fn activate_connection_future( &self, connection: Option<&(impl IsA<Connection> + Clone + 'static)>, device: Option<&(impl IsA<Device> + Clone + 'static)>, specific_object: Option<&str>, ) -> Pin<Box_<dyn Future<Output = Result<ActiveConnection, Error>> + 'static>>

Source

pub fn add_and_activate_connection_async<P: FnOnce(Result<ActiveConnection, Error>) + 'static>( &self, partial: Option<&impl IsA<Connection>>, device: Option<&impl IsA<Device>>, specific_object: Option<&str>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Adds a new connection using the given details (if any) as a template, automatically filling in missing settings with the capabilities of the given device and specific object. The new connection is then asynchronously activated as with nm_client_activate_connection_async(). Cannot be used for VPN connections at this time.

Note that the callback is invoked when NetworkManager has started activating the new connection, not when it finishes. You can used the returned #NMActiveConnection object (in particular, #NMActiveConnection:state) to track the activation to its completion.

§partial

an #NMConnection to add; the connection may be partially filled (or even None) and will be completed by NetworkManager using the given @device and @specific_object before being added

§device

the #NMDevice

§specific_object

the object path of a connection-type-specific object this activation should use. This parameter is currently ignored for wired and mobile broadband connections, and the value of None should be used (ie, no specific object). For Wi-Fi or WiMAX connections, pass the object path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can get using nm_object_get_path(), and which will be used to complete the details of the newly added connection. If the variant is floating, it will be consumed.

§cancellable

a #GCancellable, or None

§callback

callback to be called when the activation has started

Source

pub fn add_and_activate_connection_future( &self, partial: Option<&(impl IsA<Connection> + Clone + 'static)>, device: Option<&(impl IsA<Device> + Clone + 'static)>, specific_object: Option<&str>, ) -> Pin<Box_<dyn Future<Output = Result<ActiveConnection, Error>> + 'static>>

Source

pub fn add_connection_async<P: FnOnce(Result<RemoteConnection, Error>) + 'static>( &self, connection: &impl IsA<Connection>, save_to_disk: bool, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Requests that the remote settings service add the given settings to a new connection. If @save_to_disk is true, the connection is immediately written to disk; otherwise it is initially only stored in memory, but may be saved later by calling the connection’s nm_remote_connection_commit_changes() method.

@connection is untouched by this function and only serves as a template of the settings to add. The #NMRemoteConnection object that represents what NetworkManager actually added is returned to @callback when the addition operation is complete.

Note that the #NMRemoteConnection returned in @callback may not contain identical settings to @connection as NetworkManager may perform automatic completion and/or normalization of connection properties.

§connection

the connection to add. Note that this object’s settings will be added, not the object itself

§save_to_disk

whether to immediately save the connection to disk

§cancellable

a #GCancellable, or None

§callback

callback to be called when the add operation completes

Source

pub fn add_connection_future( &self, connection: &(impl IsA<Connection> + Clone + 'static), save_to_disk: bool, ) -> Pin<Box_<dyn Future<Output = Result<RemoteConnection, Error>> + 'static>>

Source

pub fn check_connectivity( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<ConnectivityState, Error>

Updates the network connectivity state and returns the (new) current state. Contrast nm_client_get_connectivity(), which returns the most recent known state without re-checking.

This is a blocking call; use nm_client_check_connectivity_async() if you do not want to block.

§Deprecated since 1.22

Use nm_client_check_connectivity_async() or GDBusConnection.

§cancellable

a #GCancellable

§Returns

the (new) current connectivity state

Source

pub fn check_connectivity_async<P: FnOnce(Result<ConnectivityState, Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Asynchronously updates the network connectivity state and invokes @callback when complete. Contrast nm_client_get_connectivity(), which (immediately) returns the most recent known state without re-checking, and nm_client_check_connectivity(), which blocks.

§cancellable

a #GCancellable

§callback

callback to call with the result

Source

pub fn check_connectivity_future( &self, ) -> Pin<Box_<dyn Future<Output = Result<ConnectivityState, Error>> + 'static>>

Source

pub fn checkpoint_adjust_rollback_timeout<P: FnOnce(Result<(), Error>) + 'static>( &self, checkpoint_path: &str, add_timeout: u32, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Available on crate feature v1_12 only.

Resets the timeout for the checkpoint with path @checkpoint_path to @timeout_add.

§checkpoint_path

a D-Bus path to a checkpoint

§add_timeout

the timeout in seconds counting from now. Set to zero, to disable the timeout.

§cancellable

a #GCancellable, or None

§callback

callback to be called when the add operation completes

Source

pub fn checkpoint_adjust_rollback_timeout_future( &self, checkpoint_path: &str, add_timeout: u32, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

Available on crate feature v1_12 only.
Source

pub fn checkpoint_create<P: FnOnce(Result<Checkpoint, Error>) + 'static>( &self, devices: &[Device], rollback_timeout: u32, flags: CheckpointCreateFlags, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Available on crate feature v1_12 only.

Creates a checkpoint of the current networking configuration for given interfaces. An empty @devices argument means all devices. If @rollback_timeout is not zero, a rollback is automatically performed after the given timeout.

§devices

a list of devices for which a checkpoint should be created.

§rollback_timeout

the rollback timeout in seconds

§flags

creation flags

§cancellable

a #GCancellable, or None

§callback

callback to be called when the add operation completes

Source

pub fn checkpoint_create_future( &self, devices: &[Device], rollback_timeout: u32, flags: CheckpointCreateFlags, ) -> Pin<Box_<dyn Future<Output = Result<Checkpoint, Error>> + 'static>>

Available on crate feature v1_12 only.
Source

pub fn checkpoint_destroy<P: FnOnce(Result<(), Error>) + 'static>( &self, checkpoint_path: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Available on crate feature v1_12 only.
Source

pub fn checkpoint_destroy_future( &self, checkpoint_path: &str, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

Available on crate feature v1_12 only.
Source

pub fn connectivity_check_get_available(&self) -> bool

Available on crate feature v1_10 only.

Determine whether connectivity checking is available. This requires that the URI of a connectivity service has been set in the configuration file.

§Returns

true if connectivity checking is available.

Source

pub fn connectivity_check_get_enabled(&self) -> bool

Available on crate feature v1_10 only.

Determine whether connectivity checking is enabled.

§Returns

true if connectivity checking is enabled.

Source

pub fn connectivity_check_get_uri(&self) -> GString

Available on crate feature v1_20 only.

Get the URI that will be queried to determine if there is internet connectivity.

§Returns

the connectivity URI in use

Source

pub fn connectivity_check_set_enabled(&self, enabled: bool)

Available on crate feature v1_10 only.

Enable or disable connectivity checking. Note that if a connectivity checking URI has not been configured, this will not have any effect.

§Deprecated since 1.22

Use the async command nm_client_dbus_set_property() on DBUS_PATH, DBUS_INTERFACE to set “ConnectivityCheckEnabled” property to a “(b)” value.

§enabled

true to enable connectivity checking

Source

pub fn deactivate_connection( &self, active: &impl IsA<ActiveConnection>, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>

Deactivates an active #NMActiveConnection.

§Deprecated since 1.22

Use nm_client_deactivate_connection_async() or GDBusConnection.

§active

the #NMActiveConnection to deactivate

§cancellable

a #GCancellable, or None

§Returns

success or failure

Source

pub fn deactivate_connection_async<P: FnOnce(Result<(), Error>) + 'static>( &self, active: &impl IsA<ActiveConnection>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Asynchronously deactivates an active #NMActiveConnection.

§active

the #NMActiveConnection to deactivate

§cancellable

a #GCancellable, or None

§callback

callback to be called when the deactivation has completed

Source

pub fn deactivate_connection_future( &self, active: &(impl IsA<ActiveConnection> + Clone + 'static), ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

Source

pub fn activating_connection(&self) -> ActiveConnection

Gets the #NMActiveConnection corresponding to a currently-activating connection that is expected to become the new #NMClient:primary-connection upon successful activation.

§Returns

the appropriate #NMActiveConnection, if any.

Source

pub fn active_connections(&self) -> Vec<ActiveConnection>

Gets the active connections.

§Returns

a #GPtrArray containing all the active #NMActiveConnections. The returned array is owned by the client and should not be modified.

Source

pub fn all_devices(&self) -> Vec<Device>

Available on crate feature v1_2 only.

Gets both real devices and device placeholders (eg, software devices which do not currently exist, but could be created automatically by NetworkManager if one of their NMDevice::ActivatableConnections was activated). Use nm_device_is_real() to determine whether each device is a real device or a placeholder.

Use nm_device_get_type() or the NM_IS_DEVICE_XXXX() functions to determine what kind of device each member of the returned array is, and then you may use device-specific methods such as nm_device_ethernet_get_hw_address().

§Returns

a #GPtrArray containing all the #NMDevices. The returned array is owned by the #NMClient object and should not be modified.

Source

pub fn checkpoints(&self) -> Vec<Checkpoint>

Available on crate feature v1_12 only.

Gets all the active checkpoints.

§Returns

a #GPtrArray containing all the #NMCheckpoint. The returned array is owned by the #NMClient object and should not be modified.

Source

pub fn connection_by_id(&self, id: &str) -> RemoteConnection

Returns the first matching NMRemoteConnection matching a given @id.

§id

the id of the remote connection

§Returns

the remote connection object on success, or None if no matching object was found.

The connection is as received from D-Bus and might not validate according to nm_connection_verify().

Source

pub fn connection_by_path(&self, path: &str) -> RemoteConnection

Returns the NMRemoteConnection representing the connection at @path.

§path

the D-Bus object path of the remote connection

§Returns

the remote connection object on success, or None if the object was not known

The connection is as received from D-Bus and might not validate according to nm_connection_verify().

Source

pub fn connection_by_uuid(&self, uuid: &str) -> RemoteConnection

Returns the NMRemoteConnection identified by @uuid.

§uuid

the UUID of the remote connection

§Returns

the remote connection object on success, or None if the object was not known

The connection is as received from D-Bus and might not validate according to nm_connection_verify().

Source

pub fn connections(&self) -> Vec<RemoteConnection>

§Returns

an array containing all connections provided by the remote settings service. The returned array is owned by the #NMClient object and should not be modified.

The connections are as received from D-Bus and might not validate according to nm_connection_verify().

Examples found in repository?
examples/get_password.rs (line 5)
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

pub fn connectivity(&self) -> ConnectivityState

Gets the current network connectivity state. Contrast nm_client_check_connectivity() and nm_client_check_connectivity_async(), which re-check the connectivity state first before returning any information.

§Returns

the current connectivity state

Source

pub fn device_by_iface(&self, iface: &str) -> Device

Gets a #NMDevice from a #NMClient.

§iface

the interface name to search for

§Returns

the #NMDevice for the given @iface or None if none is found.

Source

pub fn device_by_path(&self, object_path: &str) -> Device

Gets a #NMDevice from a #NMClient.

§object_path

the object path to search for

§Returns

the #NMDevice for the given @object_path or None if none is found.

Source

pub fn devices(&self) -> Vec<Device>

Gets all the known network devices. Use nm_device_get_type() or the NM_IS_DEVICE_XXXX functions to determine what kind of device member of the returned array is, and then you may use device-specific methods such as nm_device_ethernet_get_hw_address().

§Returns

a #GPtrArray containing all the #NMDevices. The returned array is owned by the #NMClient object and should not be modified.

Examples found in repository?
examples/get_device_type.rs (line 5)
4fn print_devices(client: &Client) {
5    let devices = client.devices();
6
7    for device in devices {
8        let name = device.iface();
9        println!(
10            "The network interface {name} is a {:#?} device.",
11            device.device_type()
12        );
13    }
14}
Source

pub fn dns_configuration(&self) -> Vec<DnsEntry>

Available on crate feature v1_6 only.

Gets the current DNS configuration

§Returns

a #GPtrArray containing #NMDnsEntry elements or None in case the value is not available. The returned array is owned by the #NMClient object and should not be modified.

Source

pub fn dns_mode(&self) -> GString

Available on crate feature v1_6 only.

Gets the current DNS processing mode.

§Returns

the DNS processing mode, or None in case the value is not available.

Source

pub fn dns_rc_manager(&self) -> GString

Available on crate feature v1_6 only.

Gets the current DNS resolv.conf manager.

§Returns

the resolv.conf manager or None in case the value is not available.

Source

pub fn logging(&self) -> Result<(Option<GString>, Option<GString>), Error>

Gets NetworkManager current logging level and domains.

§Deprecated since 1.22

Use the async command nm_client_dbus_call() on DBUS_PATH, DBUS_INTERFACE to call “GetLogging” with no arguments to get “(ss)” for level and domains.

§Returns

true on success, false otherwise

§level

return location for logging level string

§domains

return location for log domains string. The string is a list of domains separated by “,”

Source

pub fn is_nm_running(&self) -> bool

Determines whether the daemon is running.

§Returns

true if the daemon is running

Source

pub fn permission_result( &self, permission: ClientPermission, ) -> ClientPermissionResult

Requests the result of a specific permission, which indicates whether the client can or cannot perform the action the permission represents

§permission

the permission for which to return the result, one of #NMClientPermission

§Returns

the permission’s result, one of #NMClientPermissionResult

Source

pub fn primary_connection(&self) -> ActiveConnection

Gets the #NMActiveConnection corresponding to the primary active network device.

In particular, when there is no VPN active, or the VPN does not have the default route, this returns the active connection that has the default route. If there is a VPN active with the default route, then this function returns the active connection that contains the route to the VPN endpoint.

If there is no default route, or the default route is over a non-NetworkManager-recognized device, this will return None.

§Returns

the appropriate #NMActiveConnection, if any

Source

pub fn is_startup(&self) -> bool

Tests whether the daemon is still in the process of activating connections at startup.

§Returns

whether the daemon is still starting up

Source

pub fn state(&self) -> State

Gets the current daemon state.

§Returns

the current NMState

Source

pub fn version(&self) -> GString

Gets NetworkManager version.

§Returns

string with the version (or None if NetworkManager is not running)

Source

pub fn version_info(&self) -> Vec<u32>

Available on crate feature v1_42 only.

If available, the first element in the array is NM_VERSION which encodes the daemon version as “(major << 16 | minor << 8 | micro)”. The following elements are a bitfield of NMVersionInfoCapability that indicate that the daemon supports a certain capability.

§Returns

the list of capabilities reported by the server or None if the capabilities are unknown.

Source

pub fn load_connections( &self, filenames: &[&str], cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<GString, Error>

Requests that the remote settings service load or reload the given files, adding or updating the connections described within.

The changes to the indicated files will not yet be reflected in @self’s connections array when the function returns.

If all of the indicated files were successfully loaded, the function will return true, and @failures will be set to None. If NetworkManager tried to load the files, but some (or all) failed, then @failures will be set to a None-terminated array of the filenames that failed to load.

§Deprecated since 1.22

Use nm_client_load_connections_async() or GDBusConnection.

§filenames

None-terminated array of filenames to load

§cancellable

a #GCancellable, or None

§Returns

true on success.

Warning: before libnm 1.22, the boolean return value was inconsistent. That is made worse, because when running against certain server versions before 1.20, the server would return wrong values for success/failure. This means, if you use this function in libnm before 1.22, you are advised to ignore the boolean return value and only look at @failures and @error. With libnm >= 1.22, the boolean return value corresponds to whether @error was set. Note that even in the success case, you might have individual @failures. With 1.22, the return value is consistent with nm_client_load_connections_finish().

§failures

on return, a None-terminated array of filenames that failed to load

Source

pub fn load_connections_async<P: FnOnce(Result<Vec<GString>, Error>) + 'static>( &self, filenames: &[&str], cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Requests that the remote settings service asynchronously load or reload the given files, adding or updating the connections described within.

See nm_client_load_connections() for more details.

§filenames

None-terminated array of filenames to load

§cancellable

a #GCancellable, or None

§callback

callback to be called when the operation completes

Source

pub fn load_connections_future( &self, filenames: &[&str], ) -> Pin<Box_<dyn Future<Output = Result<Vec<GString>, Error>> + 'static>>

Source

pub fn networking_get_enabled(&self) -> bool

Whether networking is enabled or disabled.

§Returns

true if networking is enabled, false if networking is disabled

Source

pub fn networking_set_enabled(&self, enabled: bool) -> Result<(), Error>

Enables or disables networking. When networking is disabled, all controlled interfaces are disconnected and deactivated. When networking is enabled, all controlled interfaces are available for activation.

§Deprecated since 1.22

Use the async command nm_client_dbus_call() on DBUS_PATH, DBUS_INTERFACE to call “Enable” with “(b)” arguments and no return value.

§enabled

true to set networking enabled, false to set networking disabled

§Returns

true on success, false otherwise

Source

pub fn reload_connections( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>

Requests that the remote settings service reload all connection files from disk, adding, updating, and removing connections until the in-memory state matches the on-disk state.

§Deprecated since 1.22

Use nm_client_reload_connections_async() or GDBusConnection.

§cancellable

a #GCancellable, or None

§Returns

true on success, false on failure

Source

pub fn reload_connections_async<P: FnOnce(Result<(), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Requests that the remote settings service begin reloading all connection files from disk, adding, updating, and removing connections until the in-memory state matches the on-disk state.

§cancellable

a #GCancellable, or None

§callback

callback to be called when the reload operation completes

Source

pub fn reload_connections_future( &self, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

Source

pub fn save_hostname( &self, hostname: Option<&str>, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>

Requests that the machine’s persistent hostname be set to the specified value or cleared.

§Deprecated since 1.22

Use nm_client_save_hostname_async() or GDBusConnection.

§hostname

the new persistent hostname to set, or None to clear any existing persistent hostname

§cancellable

a #GCancellable, or None

§Returns

true if the request was successful, false if it failed

Source

pub fn save_hostname_async<P: FnOnce(Result<(), Error>) + 'static>( &self, hostname: Option<&str>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Requests that the machine’s persistent hostname be set to the specified value or cleared.

§hostname

the new persistent hostname to set, or None to clear any existing persistent hostname

§cancellable

a #GCancellable, or None

§callback

callback to be called when the operation completes

Source

pub fn save_hostname_future( &self, hostname: Option<&str>, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

Source

pub fn set_logging( &self, level: Option<&str>, domains: Option<&str>, ) -> Result<(), Error>

Sets NetworkManager logging level and/or domains.

§Deprecated since 1.22

Use the async command nm_client_dbus_call() on DBUS_PATH, DBUS_INTERFACE to call “SetLogging” with “(ss)” arguments for level and domains.

§level

logging level to set (None or an empty string for no change)

§domains

logging domains to set. The string should be a list of log domains separated by “,”. (None or an empty string for no change)

§Returns

true on success, false otherwise

Source

pub fn wait_shutdown<P: FnOnce(Result<(), Error>) + 'static>( &self, integrate_maincontext: bool, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Available on crate feature v1_42 only.

The way to stop #NMClient is by unrefing it. That will cancel all internally pending async operations. However, as async operations in NMClient use GTask, hence they cannot complete right away. Instead, their (internal) result callback still needs to be dispatched by iterating the client’s main context.

You thus cannot stop iterating the client’s main context until everything is wrapped up. nm_client_get_context_busy_watcher() helps to watch how long that will be.

This function automates that waiting. Like all glib async operations this honors the current g_main_context_get_thread_default().

In any case, to complete the shutdown, nm_client_get_main_context() must be iterated. If the current g_main_context_get_thread_default() is the same as nm_client_get_main_context(), then @integrate_maincontext is ignored. In that case, the caller is required to iterate the context for shutdown to complete. Otherwise, if g_main_context_get_thread_default() differs from nm_client_get_main_context() and @integrate_maincontext is false, the caller must make sure that both contexts are iterated until completion. Otherwise, if @integrate_maincontext is true, then nm_client_get_main_context() will be integrated in g_main_context_get_thread_default(). This means, the caller gives nm_client_get_main_context() up until the waiting completes, the function will acquire the context and hook it into g_main_context_get_thread_default(). It is a bug to request @integrate_maincontext while having nm_client_get_main_context() acquired or iterated otherwise because a context can only be acquired once at a time.

Shutdown can only complete after all references to @self were released.

It is possible to call this function multiple times for the same client. But note that with @integrate_maincontext the client’s context is acquired, which can only be done once at a time.

It is permissible to start waiting before the objects is fully initialized.

The function really allows two separate things. To get a notification (callback) when shutdown is complete, and to integrate the client’s context in another context. The latter case is useful if the client has a separate context and you hand it over to another GMainContext to wrap up.

The main use is to have a NMClient and a separate GMainContext on a worker thread. When being done, you can hand over the cleanup of the context to g_main_context_default(), assuming that the main thread iterates the default context. In that case, you don’t need to care about passing a callback to know when shutdown completed.

§integrate_maincontext

whether to hook the client’s maincontext in the current thread default. Otherwise, you must ensure that the client’s maincontext gets iterated so that it can complete. By integrating the maincontext in the current thread default, you may instead only iterate the latter.

§cancellable

the #GCancellable to abort the shutdown.

§callback

a #GAsyncReadyCallback to call when the request is satisfied or None if you don’t care about the result of the method invocation.

Source

pub fn wait_shutdown_future( &self, integrate_maincontext: bool, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>

Available on crate feature v1_42 only.
Source

pub fn wimax_get_enabled(&self) -> bool

Determines whether WiMAX is enabled.

§Deprecated since 1.22

This function always returns FALSE because WiMax is no longer supported.

§Returns

true if WiMAX is enabled

Source

pub fn wimax_hardware_get_enabled(&self) -> bool

Determines whether the WiMAX hardware is enabled.

§Deprecated since 1.22

This function always returns FALSE because WiMax is no longer supported.

§Returns

true if the WiMAX hardware is enabled

Source

pub fn wimax_set_enabled(&self, enabled: bool)

Enables or disables WiMAX devices.

§Deprecated since 1.22

This function does nothing because WiMax is no longer supported.

§enabled

true to enable WiMAX

Source

pub fn wireless_get_enabled(&self) -> bool

Determines whether the wireless is enabled.

§Returns

true if wireless is enabled

Source

pub fn wireless_hardware_get_enabled(&self) -> bool

Determines whether the wireless hardware is enabled.

§Returns

true if the wireless hardware is enabled

Source

pub fn wireless_set_enabled(&self, enabled: bool)

Enables or disables wireless devices.

§Deprecated since 1.22

Use the async command nm_client_dbus_set_property() on DBUS_PATH, DBUS_INTERFACE to set “WirelessEnabled” property to a “(b)” value.

§enabled

true to enable wireless

Source

pub fn wwan_get_enabled(&self) -> bool

Determines whether WWAN is enabled.

§Returns

true if WWAN is enabled

Source

pub fn wwan_hardware_get_enabled(&self) -> bool

Determines whether the WWAN hardware is enabled.

§Returns

true if the WWAN hardware is enabled

Source

pub fn wwan_set_enabled(&self, enabled: bool)

Enables or disables WWAN devices.

§Deprecated since 1.22

Use the async command nm_client_dbus_set_property() on DBUS_PATH, DBUS_INTERFACE to set “WwanEnabled” property to a “(b)” value.

§enabled

true to enable WWAN

Source

pub fn can_modify(&self) -> bool

If true, adding and modifying connections is supported.

Source

pub fn is_connectivity_check_available(&self) -> bool

Source

pub fn is_connectivity_check_enabled(&self) -> bool

Source

pub fn set_connectivity_check_enabled(&self, connectivity_check_enabled: bool)

Source

pub fn hostname(&self) -> Option<GString>

The machine hostname stored in persistent configuration. This can be modified by calling nm_client_save_hostname().

Source

pub fn metered(&self) -> u32

Available on non-crate feature v1_22 only.
Source

pub fn is_networking_enabled(&self) -> bool

Whether networking is enabled.

The property setter is a synchronous D-Bus call. This is deprecated since 1.22.

Source

pub fn set_networking_enabled(&self, networking_enabled: bool)

Whether networking is enabled.

The property setter is a synchronous D-Bus call. This is deprecated since 1.22.

Source

pub fn is_wimax_enabled(&self) -> bool

Whether WiMAX functionality is enabled.

§Deprecated since 1.22

WiMAX is no longer supported and this always returns FALSE. The setter has no effect.

Source

pub fn set_wimax_enabled(&self, wimax_enabled: bool)

Whether WiMAX functionality is enabled.

§Deprecated since 1.22

WiMAX is no longer supported and this always returns FALSE. The setter has no effect.

Source

pub fn is_wimax_hardware_enabled(&self) -> bool

Whether the WiMAX hardware is enabled.

§Deprecated since 1.22

WiMAX is no longer supported and this always returns FALSE.

Source

pub fn is_wireless_enabled(&self) -> bool

Whether wireless is enabled.

The property setter is a synchronous D-Bus call. This is deprecated since 1.22.

Source

pub fn set_wireless_enabled(&self, wireless_enabled: bool)

Whether wireless is enabled.

The property setter is a synchronous D-Bus call. This is deprecated since 1.22.

Source

pub fn is_wireless_hardware_enabled(&self) -> bool

Whether the wireless hardware is enabled.

Source

pub fn is_wwan_enabled(&self) -> bool

Whether WWAN functionality is enabled.

The property setter is a synchronous D-Bus call. This is deprecated since 1.22.

Source

pub fn set_wwan_enabled(&self, wwan_enabled: bool)

Whether WWAN functionality is enabled.

The property setter is a synchronous D-Bus call. This is deprecated since 1.22.

Source

pub fn is_wwan_hardware_enabled(&self) -> bool

Whether the WWAN hardware is enabled.

Source

pub fn new_async<P: FnOnce(Result<Client, Error>) + 'static>( cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Creates a new #NMClient asynchronously. @callback will be called when it is done. Use nm_client_new_finish() to get the result.

This does nothing beside calling g_async_initable_new_async(). You are free to call g_async_initable_new_async() or g_object_new()/g_async_initable_init_async() directly for more control, to set GObject properties or get access to the NMClient instance while it is still initializing.

Creating an #NMClient instance can only fail for two reasons. First, if you didn’t provide a CLIENT_DBUS_CONNECTION and the call to g_bus_get() fails. You can avoid that by using g_async_initable_new_async() directly and set a D-Bus connection. Second, if you cancelled the creation. If you do that, then note that after the failure there might still be idle actions pending which keep nm_client_get_main_context() alive. That means, in that case you must continue iterating the context to avoid leaks. See nm_client_get_context_busy_watcher().

Creating an #NMClient instance when NetworkManager is not running does not cause a failure.

§cancellable

a #GCancellable, or None

§callback

callback to call when the client is created

Source

pub fn new_future() -> Pin<Box_<dyn Future<Output = Result<Client, Error>> + 'static>>

Examples found in repository?
examples/get_password.rs (line 22)
16fn main() {
17    let mainloop = glib::MainLoop::new(None, false);
18    mainloop.context().spawn_local(glib::clone!(
19        #[strong]
20        mainloop,
21        async move {
22            let client = match Client::new_future().await {
23                Ok(client) => client,
24                Err(e) => {
25                    glib::g_error!("app", "Failed to create new client: {e}");
26                    return;
27                }
28            };
29            get_password(&client);
30            mainloop.quit();
31        }
32    ));
33    mainloop.run();
34}
More examples
Hide additional examples
examples/get_device_type.rs (line 24)
16fn main() {
17    let context = glib::MainContext::new();
18    let mainloop = glib::MainLoop::new(Some(&context), false);
19
20    context.spawn_local(glib::clone!(
21        #[strong]
22        mainloop,
23        async move {
24            let client = match Client::new_future().await {
25                Ok(client) => client,
26                Err(e) => {
27                    glib::g_error!("app", "Failed to create new client: {e}");
28                    return;
29                }
30            };
31            print_devices(&client);
32            mainloop.quit();
33        }
34    ));
35
36    mainloop.run();
37}
Source

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

Notifies that a #NMActiveConnection has been added.

§active_connection

the new active connection

Source

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

Notifies that a #NMActiveConnection has been removed.

§active_connection

the removed active connection

Source

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

Notifies that a #NMDevice is added. This signal is emitted for both regular devices and placeholder devices.

§device

the new device

Source

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

Notifies that a #NMDevice is removed. This signal is emitted for both regular devices and placeholder devices.

§device

the removed device

Source

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

Notifies that a #NMConnection has been added.

§connection

the new connection

Source

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

Notifies that a #NMConnection has been removed.

§connection

the removed connection

Source

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

Notifies that a #NMDevice is added. This signal is not emitted for placeholder devices.

§device

the new device

Source

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

Notifies that a #NMDevice is removed. This signal is not emitted for placeholder devices.

§device

the removed device

Source

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

Notifies that a permission has changed

§permission

a permission from #NMClientPermission

§result

the permission’s result, one of #NMClientPermissionResult

Source

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

Source

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

Source

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

Available on crate feature v1_2 only.
Source

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

Source

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

Available on crate feature v1_12 only.
Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Available on crate feature v1_6 only.
Source

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

Available on crate feature v1_6 only.
Source

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

Available on crate feature v1_6 only.
Source

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

Source

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

Available on crate feature v1_2 only.
Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Available on crate feature v1_42 only.
Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Self

Makes a clone of this shared reference.

This increments the strong reference count of the object. Dropping the object will decrement it again.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Client

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl HasParamSpec for Client

Source§

type ParamSpec = ParamSpecObject

Source§

type SetValue = Client

Preferred value to be used as setter for the associated ParamSpec.
Source§

type BuilderFn = fn(&str) -> ParamSpecObjectBuilder<'_, Client>

Source§

fn param_spec_builder() -> Self::BuilderFn

Source§

impl Hash for Client

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Hashes the memory address of this object.

1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Client

Source§

fn cmp(&self, other: &Self) -> Ordering

Comparison for two GObjects.

Compares the memory addresses of the provided objects.

1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl ParentClassIs for Client

Source§

impl<OT: ObjectType> PartialEq<OT> for Client

Source§

fn eq(&self, other: &OT) -> bool

Equality for two GObjects.

Two GObjects are equal if their memory addresses are equal.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<OT: ObjectType> PartialOrd<OT> for Client

Source§

fn partial_cmp(&self, other: &OT) -> Option<Ordering>

Partial comparison for two GObjects.

Compares the memory addresses of the provided objects.

1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StaticType for Client

Source§

fn static_type() -> Type

Returns the type identifier of Self.
Source§

impl Eq for Client

Auto Trait Implementations§

§

impl Freeze for Client

§

impl RefUnwindSafe for Client

§

impl !Send for Client

§

impl !Sync for Client

§

impl Unpin for Client

§

impl UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Cast for T
where T: ObjectType,

Source§

fn upcast<T>(self) -> T
where T: ObjectType, Self: IsA<T>,

Upcasts an object to a superclass or interface T. Read more
Source§

fn upcast_ref<T>(&self) -> &T
where T: ObjectType, Self: IsA<T>,

Upcasts an object to a reference of its superclass or interface T. Read more
Source§

fn downcast<T>(self) -> Result<T, Self>
where T: ObjectType, Self: MayDowncastTo<T>,

Tries to downcast to a subclass or interface implementor T. Read more
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: ObjectType, Self: MayDowncastTo<T>,

Tries to downcast to a reference of its subclass or interface implementor T. Read more
Source§

fn dynamic_cast<T>(self) -> Result<T, Self>
where T: ObjectType,

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while upcast will do many checks at compile-time already. downcast will perform the same checks at runtime as dynamic_cast, but will also ensure some amount of compile-time safety. Read more
Source§

fn dynamic_cast_ref<T>(&self) -> Option<&T>
where T: ObjectType,

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Source§

unsafe fn unsafe_cast<T>(self) -> T
where T: ObjectType,

Casts to T unconditionally. Read more
Source§

unsafe fn unsafe_cast_ref<T>(&self) -> &T
where T: ObjectType,

Casts to &T unconditionally. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoClosureReturnValue for T
where T: Into<Value>,

Source§

impl<U> IsSubclassableExt for U

Source§

impl<T> ObjectExt for T
where T: ObjectType,

Source§

fn is<U>(&self) -> bool
where U: StaticType,

Returns true if the object is an instance of (can be cast to) T.
Source§

fn type_(&self) -> Type

Returns the type of the object.
Source§

fn object_class(&self) -> &Class<Object>

Returns the ObjectClass of the object. Read more
Source§

fn class(&self) -> &Class<T>
where T: IsClass,

Returns the class of the object.
Source§

fn class_of<U>(&self) -> Option<&Class<U>>
where U: IsClass,

Returns the class of the object in the given type T. Read more
Source§

fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>
where U: IsInterface,

Returns the interface T of the object. Read more
Source§

fn set_property(&self, property_name: &str, value: impl Into<Value>)

Sets the property property_name of the object to value value. Read more
Source§

fn set_property_from_value(&self, property_name: &str, value: &Value)

Sets the property property_name of the object to value value. Read more
Source§

fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])

Sets multiple properties of the object at once. Read more
Source§

fn set_properties_from_value(&self, property_values: &[(&str, Value)])

Sets multiple properties of the object at once. Read more
Source§

fn property<V>(&self, property_name: &str) -> V
where V: for<'b> FromValue<'b> + 'static,

Gets the property property_name of the object and cast it to the type V. Read more
Source§

fn property_value(&self, property_name: &str) -> Value

Gets the property property_name of the object. Read more
Source§

fn has_property(&self, property_name: &str) -> bool

Check if the object has a property property_name.
Source§

fn has_property_with_type(&self, property_name: &str, type_: Type) -> bool

Check if the object has a property property_name of the given type_.
Source§

fn property_type(&self, property_name: &str) -> Option<Type>

Get the type of the property property_name of this object. Read more
Source§

fn find_property(&self, property_name: &str) -> Option<ParamSpec>

Get the ParamSpec of the property property_name of this object.
Source§

fn list_properties(&self) -> PtrSlice<ParamSpec>

Return all ParamSpec of the properties of this object.
Source§

fn freeze_notify(&self) -> PropertyNotificationFreezeGuard

Freeze all property notifications until the return guard object is dropped. Read more
Source§

unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)
where QD: 'static,

Set arbitrary data on this object with the given key. Read more
Source§

unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>
where QD: 'static,

Return previously set arbitrary data of this object with the given key. Read more
Source§

unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>
where QD: 'static,

Retrieve previously set arbitrary data of this object with the given key. Read more
Source§

unsafe fn set_data<QD>(&self, key: &str, value: QD)
where QD: 'static,

Set arbitrary data on this object with the given key. Read more
Source§

unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>
where QD: 'static,

Return previously set arbitrary data of this object with the given key. Read more
Source§

unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>
where QD: 'static,

Retrieve previously set arbitrary data of this object with the given key. Read more
Source§

fn block_signal(&self, handler_id: &SignalHandlerId)

Block a given signal handler. Read more
Source§

fn unblock_signal(&self, handler_id: &SignalHandlerId)

Unblock a given signal handler.
Source§

fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)

Stop emission of the currently emitted signal.
Source§

fn stop_signal_emission_by_name(&self, signal_name: &str)

Stop emission of the currently emitted signal by the (possibly detailed) signal name.
Source§

fn connect<F>( &self, signal_name: &str, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,

Connect to the signal signal_name on this object. Read more
Source§

fn connect_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,

Connect to the signal signal_id on this object. Read more
Source§

fn connect_local<F>( &self, signal_name: &str, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + 'static,

Connect to the signal signal_name on this object. Read more
Source§

fn connect_local_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value> + 'static,

Connect to the signal signal_id on this object. Read more
Source§

unsafe fn connect_unsafe<F>( &self, signal_name: &str, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value>,

Connect to the signal signal_name on this object. Read more
Source§

unsafe fn connect_unsafe_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> SignalHandlerId
where F: Fn(&[Value]) -> Option<Value>,

Connect to the signal signal_id on this object. Read more
Source§

fn connect_closure( &self, signal_name: &str, after: bool, closure: RustClosure, ) -> SignalHandlerId

Connect a closure to the signal signal_name on this object. Read more
Source§

fn connect_closure_id( &self, signal_id: SignalId, details: Option<Quark>, after: bool, closure: RustClosure, ) -> SignalHandlerId

Connect a closure to the signal signal_id on this object. Read more
Source§

fn watch_closure(&self, closure: &impl AsRef<Closure>)

Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to invoke_with_values, or invoke when using Rust closures.
Source§

fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> R

Emit signal by signal id. Read more
Source§

fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>

Same as Self::emit but takes Value for the arguments.
Source§

fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> R

Emit signal by its name. Read more
Source§

fn emit_by_name_with_values( &self, signal_name: &str, args: &[Value], ) -> Option<Value>

Emit signal by its name. Read more
Source§

fn emit_by_name_with_details<R>( &self, signal_name: &str, details: Quark, args: &[&dyn ToValue], ) -> R

Emit signal by its name with details. Read more
Source§

fn emit_by_name_with_details_and_values( &self, signal_name: &str, details: Quark, args: &[Value], ) -> Option<Value>

Emit signal by its name with details. Read more
Source§

fn emit_with_details<R>( &self, signal_id: SignalId, details: Quark, args: &[&dyn ToValue], ) -> R

Emit signal by signal id with details. Read more
Source§

fn emit_with_details_and_values( &self, signal_id: SignalId, details: Quark, args: &[Value], ) -> Option<Value>

Emit signal by signal id with details. Read more
Source§

fn disconnect(&self, handler_id: SignalHandlerId)

Disconnect a previously connected signal handler.
Source§

fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId
where F: Fn(&T, &ParamSpec) + Send + Sync + 'static,

Connect to the notify signal of the object. Read more
Source§

fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId
where F: Fn(&T, &ParamSpec) + 'static,

Connect to the notify signal of the object. Read more
Source§

unsafe fn connect_notify_unsafe<F>( &self, name: Option<&str>, f: F, ) -> SignalHandlerId
where F: Fn(&T, &ParamSpec),

Connect to the notify signal of the object. Read more
Source§

fn notify(&self, property_name: &str)

Notify that the given property has changed its value. Read more
Source§

fn notify_by_pspec(&self, pspec: &ParamSpec)

Notify that the given property has changed its value. Read more
Source§

fn downgrade(&self) -> WeakRef<T>

Downgrade this object to a weak reference.
Source§

fn add_weak_ref_notify<F>(&self, f: F) -> WeakRefNotify<T>
where F: FnOnce() + Send + 'static,

Add a callback to be notified when the Object is disposed.
Source§

fn add_weak_ref_notify_local<F>(&self, f: F) -> WeakRefNotify<T>
where F: FnOnce() + 'static,

Add a callback to be notified when the Object is disposed. Read more
Source§

fn bind_property<'a, 'f, 't, O>( &'a self, source_property: &'a str, target: &'a O, target_property: &'a str, ) -> BindingBuilder<'a, 'f, 't>
where O: ObjectType,

Bind property source_property on this object to the target_property on the target object. Read more
Source§

fn ref_count(&self) -> u32

Returns the strong reference count of this object.
Source§

unsafe fn run_dispose(&self)

Runs the dispose mechanism of the object. Read more
Source§

impl<T> Property for T
where T: HasParamSpec,

Source§

type Value = T

Source§

impl<T> PropertyGet for T
where T: HasParamSpec,

Source§

type Value = T

Source§

fn get<R, F>(&self, f: F) -> R
where F: Fn(&<T as PropertyGet>::Value) -> R,

Source§

impl<T> StaticTypeExt for T
where T: StaticType,

Source§

fn ensure_type()

Ensures that the type has been registered with the type system.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TransparentType for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T> TryFromClosureReturnValue for T
where T: for<'a> FromValue<'a> + StaticType + 'static,

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<'a, T, C, E> FromValueOptional<'a> for T
where T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,

Source§

impl<Super, Sub> MayDowncastTo<Sub> for Super
where Super: IsA<Super>, Sub: IsA<Super>,