Skip to content

link: add Display + FromStr impls for bridge enums#267

Merged
cathay4t merged 1 commit into
rust-netlink:mainfrom
cathay4t:main
Jun 2, 2026
Merged

link: add Display + FromStr impls for bridge enums#267
cathay4t merged 1 commit into
rust-netlink:mainfrom
cathay4t:main

Conversation

@cathay4t

@cathay4t cathay4t commented Jun 2, 2026

Copy link
Copy Markdown
Member

Add Display and FromStr implementations for bridge-related enums
to eliminate manual parsing/formatting in downstream crates:

  BridgeStpState        Display: "no"/"kernel_stp"/"user_stp"
                        FromStr: accepts name and numeric ("0"/"1"/"2")
  BridgeMulticastRouterType  Display: "disabled"/"auto"/"permanent"/"temp"
                             FromStr: accepts name and numeric
  BridgePortState       Display: "disabled"/"listening"/"learning"/
                                 "forwarding"/"blocking"
                        FromStr: accepts string names
  BridgeFlag            Display: "master"/"self"
                        FromStr: accepts string names
  BridgeMode            Display: "veb"/"vepa"
                        FromStr: accepts string names
  VlanProtocol          FromStr: case-insensitive "802.1q"/"802.1ad"
                        (Display already existed)

Other(d) variants produce raw numeric values matching iproute2 output.

@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.67%. Comparing base (1fb4bd7) to head (25c4946).
⚠️ Report is 51 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #267      +/-   ##
==========================================
+ Coverage   68.10%   68.67%   +0.56%     
==========================================
  Files         144      146       +2     
  Lines       10103    10525     +422     
==========================================
+ Hits         6881     7228     +347     
- Misses       3222     3297      +75     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request implements 'std::fmt::Display' and 'std::str::FromStr' for several bridge-related enums ('BridgeFlag', 'BridgeMode', 'BridgeStpState', 'BridgeMulticastRouterType', 'BridgePortState', and 'VlanProtocol'). The reviewer suggests improving the 'Display' and 'FromStr' implementations for the bridge enums to ensure correct round-tripping of their 'Other' variants by parsing fallback values. Additionally, for 'VlanProtocol', the reviewer recommends using 'eq_ignore_ascii_case' instead of 'to_lowercase()' to prevent unnecessary heap allocations.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/link/af_spec/bridge.rs
Comment thread src/link/af_spec/bridge.rs
Comment thread src/link/link_info/bridge.rs
Comment thread src/link/link_info/bridge.rs
Comment thread src/link/link_info/bridge_port.rs
Comment thread src/link/vlan_protocol.rs
Add Display and FromStr implementations for bridge-related enums
to eliminate manual parsing/formatting in downstream crates:

  BridgeStpState        Display: "no"/"kernel_stp"/"user_stp"
                        FromStr: accepts name and numeric ("0"/"1"/"2")
  BridgeMulticastRouterType  Display: "disabled"/"auto"/"permanent"/"temp"
                             FromStr: accepts name and numeric
  BridgePortState       Display: "disabled"/"listening"/"learning"/
                                 "forwarding"/"blocking"
                        FromStr: accepts string names
  BridgeFlag            Display: "master"/"self"
                        FromStr: accepts string names
  BridgeMode            Display: "veb"/"vepa"
                        FromStr: accepts string names
  VlanProtocol          FromStr: case-insensitive "802.1q"/"802.1ad"
                        (Display already existed)

Other(d) variants produce raw numeric values matching iproute2 output.

Signed-off-by: Gris Ge <cnfourt@gmail.com>
@cathay4t cathay4t merged commit 7c7c6a9 into rust-netlink:main Jun 2, 2026
11 checks passed
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