Skip to main content

Settings

Struct Settings 

Source
pub struct Settings {
    pub connections: Property<Vec<ConnectionSettings>>,
    pub hostname: Property<String>,
    pub can_modify: Property<bool>,
    pub version_id: Property<u64>,
    /* private fields */
}
Expand description

Connection Settings Profile Manager.

The Settings interface allows clients to view and administrate the connections stored and used by NetworkManager.

Fields§

§connections: Property<Vec<ConnectionSettings>>

List of object paths of available network connection profiles.

§hostname: Property<String>

The machine hostname stored in persistent configuration.

§can_modify: Property<bool>

If true, adding and modifying connections is supported.

§version_id: Property<u64>

The version of the settings. This is incremented whenever the profile changes and can be used to detect concurrent modifications. Since: 1.44

Implementations§

Source§

impl Settings

Source

pub async fn list_connections(&self) -> Result<Vec<OwnedObjectPath>, Error>

List the saved network connections known to NetworkManager.

§Returns

List of connection object paths.

§Errors

Returns NetworkError::DbusError if the DBus operation fails.

Source

pub async fn get_connection_by_uuid( &self, uuid: &str, ) -> Result<OwnedObjectPath, Error>

Retrieve the object path of a connection, given that connection’s UUID.

§Arguments
  • uuid - The UUID to find the connection object path for.
§Returns

The connection’s object path.

§Errors

Returns NetworkError::DbusError if the DBus operation fails or connection not found.

Source

pub async fn add_connection( &self, connection: HashMap<String, HashMap<String, OwnedValue>>, ) -> Result<OwnedObjectPath, Error>

Add new connection and save it to disk.

This operation does not start the network connection unless (1) device is idle and able to connect to the network described by the new connection AND (2) the connection is allowed to be started automatically.

§Arguments
  • connection - Connection settings and properties.
§Returns

Object path of the new connection that was just added.

§Errors

Returns NetworkError::DbusError if the DBus operation fails.

Source

pub async fn add_connection_unsaved( &self, connection: HashMap<String, HashMap<String, OwnedValue>>, ) -> Result<OwnedObjectPath, Error>

Add new connection but do not save it to disk immediately.

This operation does not start the network connection unless (1) device is idle and able to connect to the network described by the new connection, and (2) the connection is allowed to be started automatically. Use the ‘Save’ method on the connection to save these changes to disk.

§Arguments
  • connection - Connection settings and properties.
§Returns

Object path of the new connection that was just added.

§Errors

Returns NetworkError::DbusError if the DBus operation fails.

Source

pub async fn add_connection2( &self, settings: HashMap<String, HashMap<String, OwnedValue>>, flags: NMSettingsAddConnection2Flags, args: HashMap<String, OwnedValue>, ) -> Result<(OwnedObjectPath, HashMap<String, OwnedValue>), Error>

Add a new connection profile.

AddConnection2 is an alternative to AddConnection and AddConnectionUnsaved. The new variant can do everything that the older variants could, and more. Its behavior is extensible via extra flags and args arguments.

§Arguments
  • settings - Connection configuration as nested hashmaps. The outer map keys are setting names like “connection”, “802-3-ethernet”, “ipv4”, etc. The inner maps contain the properties for each setting.
  • flags - Control how the connection is stored:
    • TO_DISK: Persist the connection to disk
    • IN_MEMORY: Keep the connection in memory only
    • BLOCK_AUTOCONNECT: Prevent automatic connection until manually activated
  • args - Additional arguments:
    • "plugin": Specify storage backend like “keyfile” or “ifcfg-rh” (Since 1.38)
§Returns

Returns a tuple containing:

  • The DBus object path of the newly created connection
  • A result dictionary (currently empty but reserved for future use)
§Errors

Returns NetworkError::DbusError if the DBus operation fails.

Source

pub async fn load_connections( &self, filenames: Vec<String>, ) -> Result<(bool, Vec<String>), Error>

Loads or reloads the indicated connections from disk.

You should call this after making changes directly to an on-disk connection file to make sure that NetworkManager sees the changes. As with AddConnection(), this operation does not necessarily start the network connection.

§Arguments
  • filenames - Array of paths to on-disk connection profiles in directories monitored by NetworkManager
§Returns

Returns a tuple containing:

  • status: Success or failure of the operation as a whole. True if NetworkManager at least tried to load the indicated connections, even if it did not succeed. False if an error occurred before trying to load the connections (eg, permission denied).
  • failures: Paths of connection files that could not be loaded
§Errors

Returns NetworkError::DbusError if the DBus operation fails.

Source

pub async fn reload_connections(&self) -> Result<bool, Error>

Tells NetworkManager to reload all connection files from disk.

Reloads all connection files from disk, including noticing any added or deleted connection files.

§Returns

This always returns true.

§Errors

Returns NetworkError::DbusError if the DBus operation fails.

Source

pub async fn save_hostname(&self, hostname: &str) -> Result<(), Error>

Save the hostname to persistent configuration.

§Arguments
  • hostname - The hostname to save to persistent configuration. If blank, the persistent hostname is cleared.
§Errors

Returns NetworkError::OperationFailed if the operations fails.

Source

pub fn connections_for_ssid(&self, ssid: &Ssid) -> Vec<ConnectionSettings>

Saved connection profiles matching the given SSID.

A single SSID may have multiple profiles with different configurations.

Source

pub async fn delete_connections_for_ssid(&self, ssid: &Ssid)

Deletes all saved connection profiles for the given SSID.

Individual profile deletion errors are logged but do not stop remaining deletions.

Source

pub fn connections_for_ssid_monitored( &self, ssid: Ssid, ) -> impl Stream<Item = Vec<ConnectionSettings>> + '_

Reactive stream of saved connections for the given SSID.

Emits whenever connections are added, removed, or modified for the specified SSID.

Source

pub async fn new_connection_signal( &self, ) -> Result<impl Stream<Item = OwnedObjectPath>, Error>

Emitted when a new connection has been added.

§Errors

Returns error if D-Bus proxy creation fails.

Source

pub async fn connection_removed_signal( &self, ) -> Result<impl Stream<Item = OwnedObjectPath>, Error>

Emitted when a connection is no longer available.

§Errors

Returns error if D-Bus proxy creation fails.

Trait Implementations§

Source§

impl Clone for Settings

Source§

fn clone(&self) -> Settings

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Settings

Source§

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

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

impl ModelMonitoring for Settings

Source§

type Error = Error

Error type for monitoring operations.
Source§

async fn start_monitoring(self: Arc<Self>) -> Result<(), Self::Error>

Starts monitoring for state changes with shared ownership. Read more
Source§

impl Reactive for Settings

Source§

type Context<'a> = SettingsParams<'a>

Context type for static fetching.
Source§

type LiveContext<'a> = LiveSettingsParams<'a>

Context type for live monitoring.
Source§

type Error = Error

Error type for reactive operations.
Source§

async fn get(params: Self::Context<'_>) -> Result<Self, Self::Error>

Fetches a static snapshot without monitoring.
Source§

async fn get_live( params: Self::LiveContext<'_>, ) -> Result<Arc<Self>, Self::Error>

Fetches with live monitoring and reactive updates.

Auto Trait Implementations§

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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, 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, 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more