Work on more Rust-side bindings
This commit is contained in:
parent
91a7fc6da1
commit
da5c6ed172
7 changed files with 116 additions and 2 deletions
|
|
@ -4,11 +4,40 @@ pub mod bluetooth;
|
|||
pub mod wired;
|
||||
pub mod wireless;
|
||||
|
||||
use crate::interface::device::DeviceProxy;
|
||||
use std::ops::Deref;
|
||||
use crate::{
|
||||
config::{ip4::Ipv4Config, ip6::Ipv6Config},
|
||||
interface::{
|
||||
config::{ip4::Ipv4ConfigProxy, ip6::Ipv6ConfigProxy},
|
||||
device::DeviceProxy,
|
||||
},
|
||||
};
|
||||
use std::{net::Ipv4Addr, ops::Deref};
|
||||
use zbus::Result;
|
||||
|
||||
pub struct Device<'a>(DeviceProxy<'a>);
|
||||
|
||||
impl<'a> Device<'a> {
|
||||
pub async fn ip4_address(&self) -> Result<Ipv4Addr> {
|
||||
self.0.ip4_address().await.map(Ipv4Addr::from)
|
||||
}
|
||||
|
||||
pub async fn ip4_config(&self) -> Result<Ipv4Config<'a>> {
|
||||
let config = Ipv4ConfigProxy::builder(self.0.connection())
|
||||
.path(self.0.ip4_config().await?)?
|
||||
.build()
|
||||
.await?;
|
||||
Ok(Ipv4Config::from(config))
|
||||
}
|
||||
|
||||
pub async fn ip6_config(&self) -> Result<Ipv6Config<'a>> {
|
||||
let config = Ipv6ConfigProxy::builder(self.0.connection())
|
||||
.path(self.0.ip6_config().await?)?
|
||||
.build()
|
||||
.await?;
|
||||
Ok(Ipv6Config::from(config))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Deref for Device<'a> {
|
||||
type Target = DeviceProxy<'a>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue