Skip to content

Conversation

@cathay4t
Copy link
Member

@cathay4t cathay4t commented Feb 3, 2026

  • Align with rtnetlink crate.
  • Stream allow us to do map, join, select actions while TryStream
    cannot.

@gemini-code-assist
Copy link

Summary of Changes

Hello @cathay4t, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a significant refactoring of the asynchronous stream handling within the project. The primary goal is to transition from futures_util::TryStream to futures_util::Stream, enhancing compatibility with the rtnetlink crate and unlocking more flexible stream processing capabilities. This change impacts several API signatures, standardizing how asynchronous data and potential errors are returned and processed throughout the library.

Highlights

  • Migration to futures_util::Stream: The codebase has been refactored to replace futures_util::TryStream with futures_util::Stream across all get request implementations and the core ethtool_execute function. This aligns with the rtnetlink crate and provides access to more powerful stream combinator methods like map, join, and select.
  • Updated API Signatures: The return types of execute methods in various get modules and the ethtool_execute function have been updated. They now return Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>, standardizing error handling by embedding potential errors within the stream's item type.
  • Simplified Error Handling in ethtool_execute: The internal error handling logic within the ethtool_execute function in src/handle.rs has been streamlined. The use of the Either enum for error propagation has been removed, replaced by direct Result returns and the ? operator for cleaner code.
  • Example Code Adaptation: The examples/dump_coalesce.rs file was updated to correctly extract the payload() from the GenlMessage after receiving it from the stream, reflecting the changes in the stream's item type.
Changelog
  • examples/dump_coalesce.rs
    • Modified the message processing loop to call .payload() on the received GenlMessage before pushing it to the msgs vector.
  • src/channel/get.rs
    • Replaced use futures_util::TryStream with use futures_util::Stream.
    • Updated the execute async function's return type from impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError> to Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>.
  • src/coalesce/get.rs
    • Replaced use futures_util::TryStream with use futures_util::Stream.
    • Updated the execute async function's return type from impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError> to Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>.
  • src/eeprom/get.rs
    • Replaced use futures_util::TryStream with use futures_util::Stream.
    • Updated the execute async function's return type from impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError> to Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>.
  • src/feature/get.rs
    • Replaced use futures_util::TryStream with use futures_util::Stream.
    • Updated the execute async function's return type from impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError> to Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>.
  • src/fec/get.rs
    • Replaced use futures_util::TryStream with use futures_util::Stream.
    • Updated the execute async function's return type from impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError> to Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>.
  • src/handle.rs
    • Removed unused imports: future::Either, FutureExt, TryStream.
    • Updated the ethtool_execute async function's return type from impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError> to Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>.
    • Refactored the ethtool_execute function's body to directly return Ok(handle.request(...).await?.map(...)) instead of using a match statement with Either for error handling.
  • src/link_mode/get.rs
    • Replaced use futures_util::TryStream with use futures_util::Stream.
    • Updated the execute async function's return type from impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError> to Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>.
  • src/pause/get.rs
    • Replaced use futures_util::TryStream with use futures_util::Stream.
    • Updated the execute async function's return type from impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError> to Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>.
  • src/ring/get.rs
    • Replaced use futures_util::TryStream with use futures_util::Stream.
    • Updated the execute async function's return type from impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError> to Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>.
  • src/tsinfo/get.rs
    • Replaced use futures_util::TryStream with use futures_util::Stream.
    • Updated the execute async function's return type from impl TryStream<Ok = GenlMessage<EthtoolMessage>, Error = EthtoolError> to Result<impl Stream<Item = Result<GenlMessage<EthtoolMessage>, EthtoolError>>, EthtoolError>.
Activity
  • The author cathay4t initiated this pull request to refactor the asynchronous stream handling mechanism.
  • The changes involve updating multiple files across the src directory to align with the new Stream-based approach, including modifying imports, function signatures, and error handling patterns.
  • This PR represents a significant internal API change for how asynchronous data streams are managed and consumed within the library.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request successfully migrates the API from futures_util::TryStream to futures_util::Stream across multiple modules. This change aligns the library with the rtnetlink crate and provides more flexibility for stream operations. The updates to function signatures and the ethtool_execute function in src/handle.rs correctly reflect this transition. However, a critical issue exists in the examples/dump_coalesce.rs file, where the example code will not compile due to incorrect handling of the new Stream type.

* Align with `rtnetlink` crate.
* `Stream` allow us to do map, join, select actions while TryStream
  cannot.

Signed-off-by: Gris Ge <fge@redhat.com>
@cathay4t cathay4t merged commit 15810b2 into rust-netlink:main Feb 3, 2026
3 checks passed
@cathay4t cathay4t deleted the fix_bug branch February 3, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant