2022-01-12 11:23:09 -05:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
|
|
|
|
pub mod connection;
|
2022-01-21 11:01:06 -05:00
|
|
|
|
|
|
|
|
use self::connection::Connection;
|
2025-10-05 13:45:37 +02:00
|
|
|
use crate::interface::settings::{SettingsProxy, connection::ConnectionSettingsProxy};
|
2022-02-07 14:08:33 -05:00
|
|
|
use std::ops::Deref;
|
2022-01-21 11:01:06 -05:00
|
|
|
use zbus::Result;
|
|
|
|
|
|
2022-01-21 11:12:35 -05:00
|
|
|
#[derive(Debug)]
|
2022-01-21 11:01:06 -05:00
|
|
|
pub struct NetworkManagerSettings<'a>(SettingsProxy<'a>);
|
|
|
|
|
|
2022-02-07 14:08:33 -05:00
|
|
|
impl<'a> Deref for NetworkManagerSettings<'a> {
|
|
|
|
|
type Target = SettingsProxy<'a>;
|
|
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
|
&self.0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-21 11:01:06 -05:00
|
|
|
impl<'a> NetworkManagerSettings<'a> {
|
|
|
|
|
pub async fn new(connection: &'a zbus::Connection) -> Result<NetworkManagerSettings<'a>> {
|
|
|
|
|
SettingsProxy::new(connection).await.map(Self)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn list_connections(&'a self) -> Result<Vec<Connection<'a>>> {
|
|
|
|
|
let connections = self.0.list_connections().await?;
|
|
|
|
|
let mut out = Vec::with_capacity(connections.len());
|
|
|
|
|
for connection in connections {
|
2024-05-16 15:24:53 -04:00
|
|
|
let connection = ConnectionSettingsProxy::builder(self.0.inner().connection())
|
2022-01-21 11:01:06 -05:00
|
|
|
.path(connection)?
|
|
|
|
|
.build()
|
|
|
|
|
.await?;
|
|
|
|
|
out.push(connection.into());
|
|
|
|
|
}
|
|
|
|
|
Ok(out)
|
|
|
|
|
}
|
|
|
|
|
}
|