Skip to content

Commit 64382a5

Browse files
committed
link_mode: Support convert EthtoolLinkModeDuplex to u8
Signed-off-by: Gris Ge <fge@redhat.com>
1 parent f038c3d commit 64382a5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/link_mode/attr.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const DUPLEX_HALF: u8 = 0x00;
2323
const DUPLEX_FULL: u8 = 0x01;
2424
const DUPLEX_UNKNOWN: u8 = 0xff;
2525

26-
#[derive(Debug, PartialEq, Eq, Clone)]
26+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
2727
pub enum EthtoolLinkModeDuplex {
2828
Half,
2929
Full,
@@ -42,6 +42,17 @@ impl From<u8> for EthtoolLinkModeDuplex {
4242
}
4343
}
4444

45+
impl From<EthtoolLinkModeDuplex> for u8 {
46+
fn from(v: EthtoolLinkModeDuplex) -> u8 {
47+
match v {
48+
EthtoolLinkModeDuplex::Half => DUPLEX_HALF,
49+
EthtoolLinkModeDuplex::Full => DUPLEX_FULL,
50+
EthtoolLinkModeDuplex::Unknown => DUPLEX_UNKNOWN,
51+
EthtoolLinkModeDuplex::Other(d) => d,
52+
}
53+
}
54+
}
55+
4556
#[derive(Debug, PartialEq, Eq, Clone)]
4657
pub enum EthtoolLinkModeAttr {
4758
Header(Vec<EthtoolHeader>),

0 commit comments

Comments
 (0)