diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-18 13:34:39 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-18 13:34:39 +0100 |
commit | 526c694bcdb08da99aab6da308775fe5e0164b95 (patch) | |
tree | 376f07baebe38b0198093921c1afa1319379f448 | |
parent | 1954c7c7e975104fa651ccded4358826e8b3c8d8 (diff) |
run creation of blocking connection in a tokio runtime0.4.3
Spawning the connection requires this to be done, otherwise the caller panics.
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/blocking.rs | 4 | ||||
-rw-r--r-- | src/connection.rs | 2 |
3 files changed, 5 insertions, 3 deletions
@@ -1,6 +1,6 @@ [package] name = "rsdsl_netlinklib" -version = "0.4.2" +version = "0.4.3" 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 5e5c1f9..a60fa7c 100644 --- a/src/blocking.rs +++ b/src/blocking.rs @@ -16,7 +16,9 @@ pub struct Connection(crate::Connection); impl Connection { /// Creates a new blocking wrapper around [`crate::Connection`]. pub fn new() -> crate::Result<Self> { - Ok(Self(crate::Connection::new()?)) + Ok(Self( + tokio::runtime::Runtime::new()?.block_on(crate::Connection::new())?, + )) } } diff --git a/src/connection.rs b/src/connection.rs index 37d31f4..2cc27d5 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -9,7 +9,7 @@ impl Connection { /// Creates a new connection and handle to rtnetlink and spawns the connection task. /// Can be used to interact with rtnetlink by enabling certain crate features /// and calling the methods they provide. - pub fn new() -> Result<Self> { + pub async fn new() -> Result<Self> { let (conn, handle, _) = rtnetlink::new_connection()?; tokio::spawn(conn); |