aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-11-14 20:12:49 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-11-14 20:12:49 +0100
commitd12f01295f4a108073e7e8f9f50fc57257300950 (patch)
tree293bba01ba056b748dd9848484d9b937fa548336
parente0106ac16acde55575aa069edbb4c187e2ea4ccd (diff)
simplify link::set to use booleans instead of custom enum0.1.2
-rw-r--r--Cargo.toml2
-rw-r--r--src/blocking.rs4
-rw-r--r--src/link.rs13
3 files changed, 6 insertions, 13 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 314971f..dfbbc07 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rsdsl_netlinklib"
-version = "0.1.1"
+version = "0.1.2"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/src/blocking.rs b/src/blocking.rs
index 0dc8263..587dd1b 100644
--- a/src/blocking.rs
+++ b/src/blocking.rs
@@ -43,10 +43,10 @@ pub mod addr {
#[cfg(feature = "status")]
pub mod link {
- use crate::link::{self, LinkState};
+ use crate::link;
#[cfg(feature = "link")]
- blockify!(set, link::set, link: String, state: LinkState);
+ blockify!(set, link::set, link: String, state: bool);
#[cfg(feature = "link")]
blockify!(set_mtu, link::set_mtu, link: String, mtu: u32);
#[cfg(feature = "link")]
diff --git a/src/link.rs b/src/link.rs
index a5b33fc..209b8a6 100644
--- a/src/link.rs
+++ b/src/link.rs
@@ -9,16 +9,9 @@ use tokio::time::sleep;
use futures::TryStreamExt;
use netlink_packet_route::rtnl::IFF_UP;
-#[cfg(feature = "link")]
-#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
-pub enum LinkState {
- Up,
- Down,
-}
-
/// Brings an interface up or down.
#[cfg(feature = "link")]
-pub async fn set(link: String, state: LinkState) -> Result<()> {
+pub async fn set(link: String, state: bool) -> Result<()> {
let (conn, handle, _) = rtnetlink::new_connection()?;
tokio::spawn(conn);
@@ -34,8 +27,8 @@ pub async fn set(link: String, state: LinkState) -> Result<()> {
let id = link.header.index;
match state {
- LinkState::Up => handle.link().set(id).up(),
- LinkState::Down => handle.link().set(id).down(),
+ true => handle.link().set(id).up(),
+ false => handle.link().set(id).down(),
}
.execute()
.await?;