Skip to content

Commit f2ac86c

Browse files
committed
Change TryStream to Stream
* Align with `rtnetlink` crate. * `Stream` allow us to do map, join, select actions while TryStream cannot. Signed-off-by: Gris Ge <fge@redhat.com>
1 parent f79bc8b commit f2ac86c

22 files changed

Lines changed: 98 additions & 76 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Cargo.lock
22
target
33
vendor/
4-
4+
tags
55
*.swp

examples/dump_channels.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
use futures_util::stream::TryStreamExt;
3+
use futures_util::stream::StreamExt;
44

55
// Once we find a way to load netsimdev kernel module in CI, we can convert this
66
// to a test
@@ -16,10 +16,11 @@ async fn get_channels(iface_name: Option<&str>) {
1616
let (connection, mut handle, _) = ethtool::new_connection().unwrap();
1717
tokio::spawn(connection);
1818

19-
let mut channel_handle = handle.channel().get(iface_name).execute().await;
19+
let mut channel_handle =
20+
handle.channel().get(iface_name).execute().await.unwrap();
2021

2122
let mut msgs = Vec::new();
22-
while let Some(msg) = channel_handle.try_next().await.unwrap() {
23+
while let Some(Ok(msg)) = channel_handle.next().await {
2324
msgs.push(msg);
2425
}
2526
assert!(!msgs.is_empty());

examples/dump_coalesce.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
use futures_util::stream::TryStreamExt;
3+
use futures_util::stream::StreamExt;
44

55
// Once we find a way to load netsimdev kernel module in CI, we can convert this
66
// to a test
@@ -16,11 +16,12 @@ async fn get_coalesce(iface_name: Option<&str>) {
1616
let (connection, mut handle, _) = ethtool::new_connection().unwrap();
1717
tokio::spawn(connection);
1818

19-
let mut coalesce_handle = handle.coalesce().get(iface_name).execute().await;
19+
let mut coalesce_handle =
20+
handle.coalesce().get(iface_name).execute().await.unwrap();
2021

2122
let mut msgs = Vec::new();
22-
while let Some(msg) = coalesce_handle.try_next().await.unwrap() {
23-
msgs.push(msg);
23+
while let Some(Ok(msg)) = coalesce_handle.next().await {
24+
msgs.push(msg.payload);
2425
}
2526
assert!(!msgs.is_empty());
2627
for msg in msgs {

examples/dump_eeprom_page.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
use futures_util::stream::TryStreamExt;
3+
use futures_util::stream::StreamExt;
44

55
fn main() {
66
let rt = tokio::runtime::Builder::new_current_thread()
@@ -19,10 +19,11 @@ async fn get_eeprom(iface_name: Option<&str>) {
1919
.eeprom()
2020
.get(iface_name, 0, 1, 0, 0, 0x50)
2121
.execute()
22-
.await;
22+
.await
23+
.unwrap();
2324

2425
let mut msgs = Vec::new();
25-
while let Some(msg) = eeprom_handle.try_next().await.unwrap() {
26+
while let Some(Ok(msg)) = eeprom_handle.next().await {
2627
msgs.push(msg);
2728
}
2829
assert!(!msgs.is_empty());

examples/dump_features.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
use futures_util::stream::TryStreamExt;
3+
use futures_util::stream::StreamExt;
44

55
// Once we find a way to load netsimdev kernel module in CI, we can convert this
66
// to a test
@@ -16,10 +16,11 @@ async fn get_feature(iface_name: Option<&str>) {
1616
let (connection, mut handle, _) = ethtool::new_connection().unwrap();
1717
tokio::spawn(connection);
1818

19-
let mut feature_handle = handle.feature().get(iface_name).execute().await;
19+
let mut feature_handle =
20+
handle.feature().get(iface_name).execute().await.unwrap();
2021

2122
let mut msgs = Vec::new();
22-
while let Some(msg) = feature_handle.try_next().await.unwrap() {
23+
while let Some(Ok(msg)) = feature_handle.next().await {
2324
msgs.push(msg);
2425
}
2526
assert!(!msgs.is_empty());

examples/dump_fec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
use futures_util::stream::TryStreamExt;
3+
use futures_util::stream::StreamExt;
44

55
// Once we find a way to load netsimdev kernel module in CI, we can convert this
66
// to a test
@@ -17,10 +17,10 @@ async fn get_fec(iface_name: Option<&str>) {
1717
let (connection, mut handle, _) = ethtool::new_connection().unwrap();
1818
tokio::spawn(connection);
1919

20-
let mut fec_handle = handle.fec().get(iface_name).execute().await;
20+
let mut fec_handle = handle.fec().get(iface_name).execute().await.unwrap();
2121

2222
let mut msgs = Vec::new();
23-
while let Some(msg) = fec_handle.try_next().await.unwrap() {
23+
while let Some(Ok(msg)) = fec_handle.next().await {
2424
msgs.push(msg);
2525
}
2626
assert!(!msgs.is_empty());

examples/dump_link_mode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
use futures_util::stream::TryStreamExt;
3+
use futures_util::stream::StreamExt;
44

55
// Once we find a way to load netsimdev kernel module in CI, we can convert this
66
// to a test
@@ -17,10 +17,10 @@ async fn get_link_mode(iface_name: Option<&str>) {
1717
tokio::spawn(connection);
1818

1919
let mut link_mode_handle =
20-
handle.link_mode().get(iface_name).execute().await;
20+
handle.link_mode().get(iface_name).execute().await.unwrap();
2121

2222
let mut msgs = Vec::new();
23-
while let Some(msg) = link_mode_handle.try_next().await.unwrap() {
23+
while let Some(Ok(msg)) = link_mode_handle.next().await {
2424
msgs.push(msg);
2525
}
2626
assert!(!msgs.is_empty());

examples/dump_pause.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
use futures_util::stream::TryStreamExt;
3+
use futures_util::stream::StreamExt;
44

55
// Once we find a way to load netsimdev kernel module in CI, we can convert this
66
// to a test
@@ -17,10 +17,11 @@ async fn get_pause(iface_name: Option<&str>) {
1717
let (connection, mut handle, _) = ethtool::new_connection().unwrap();
1818
tokio::spawn(connection);
1919

20-
let mut pause_handle = handle.pause().get(iface_name).execute().await;
20+
let mut pause_handle =
21+
handle.pause().get(iface_name).execute().await.unwrap();
2122

2223
let mut msgs = Vec::new();
23-
while let Some(msg) = pause_handle.try_next().await.unwrap() {
24+
while let Some(Ok(msg)) = pause_handle.next().await {
2425
msgs.push(msg);
2526
}
2627
assert!(!msgs.is_empty());

examples/dump_rings.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
use futures_util::stream::TryStreamExt;
3+
use futures_util::stream::StreamExt;
44

55
// Once we find a way to load netsimdev kernel module in CI, we can convert this
66
// to a test
@@ -16,10 +16,11 @@ async fn get_ring(iface_name: Option<&str>) {
1616
let (connection, mut handle, _) = ethtool::new_connection().unwrap();
1717
tokio::spawn(connection);
1818

19-
let mut ring_handle = handle.ring().get(iface_name).execute().await;
19+
let mut ring_handle =
20+
handle.ring().get(iface_name).execute().await.unwrap();
2021

2122
let mut msgs = Vec::new();
22-
while let Some(msg) = ring_handle.try_next().await.unwrap() {
23+
while let Some(Ok(msg)) = ring_handle.next().await {
2324
msgs.push(msg);
2425
}
2526
assert!(!msgs.is_empty());

examples/dump_tsinfo.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
use futures_util::stream::TryStreamExt;
3+
use futures_util::stream::StreamExt;
44

55
// Once we find a way to load netsimdev kernel module in CI, we can convert this
66
// to a test
@@ -17,10 +17,11 @@ async fn get_tsinfo(iface_name: Option<&str>) {
1717
let (connection, mut handle, _) = ethtool::new_connection().unwrap();
1818
tokio::spawn(connection);
1919

20-
let mut tsinfo_handle = handle.tsinfo().get(iface_name).execute().await;
20+
let mut tsinfo_handle =
21+
handle.tsinfo().get(iface_name).execute().await.unwrap();
2122

2223
let mut msgs = Vec::new();
23-
while let Some(msg) = tsinfo_handle.try_next().await.unwrap() {
24+
while let Some(Ok(msg)) = tsinfo_handle.next().await {
2425
msgs.push(msg);
2526
}
2627
assert!(!msgs.is_empty());

0 commit comments

Comments
 (0)