@@ -302,18 +302,9 @@ impl Nla for InfoKind {
302302 }
303303}
304304
305- impl < ' a , T : AsRef < [ u8 ] > + ?Sized > Parseable < NlaBuffer < & ' a T > > for InfoKind {
306- fn parse ( buf : & NlaBuffer < & ' a T > ) -> Result < InfoKind , DecodeError > {
307- if buf. kind ( ) != IFLA_INFO_KIND {
308- return Err ( format ! (
309- "failed to parse IFLA_INFO_KIND: NLA type is {}" ,
310- buf. kind( )
311- )
312- . into ( ) ) ;
313- }
314- let s = parse_string ( buf. value ( ) )
315- . context ( "invalid IFLA_INFO_KIND value" ) ?;
316- Ok ( match s. as_str ( ) {
305+ impl From < & str > for InfoKind {
306+ fn from ( s : & str ) -> Self {
307+ match s {
317308 DUMMY => Self :: Dummy ,
318309 IFB => Self :: Ifb ,
319310 BRIDGE => Self :: Bridge ,
@@ -339,13 +330,28 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoKind {
339330 GTP => Self :: Gtp ,
340331 IPOIB => Self :: Ipoib ,
341332 WIREGUARD => Self :: Wireguard ,
342- MACSEC => Self :: MacSec ,
343333 XFRM => Self :: Xfrm ,
334+ MACSEC => Self :: MacSec ,
344335 HSR => Self :: Hsr ,
345336 GENEVE => Self :: Geneve ,
346337 NETKIT => Self :: Netkit ,
347338 VXCAN => Self :: Vxcan ,
348- _ => Self :: Other ( s) ,
349- } )
339+ _ => Self :: Other ( s. to_owned ( ) ) ,
340+ }
341+ }
342+ }
343+
344+ impl < ' a , T : AsRef < [ u8 ] > + ?Sized > Parseable < NlaBuffer < & ' a T > > for InfoKind {
345+ fn parse ( buf : & NlaBuffer < & ' a T > ) -> Result < InfoKind , DecodeError > {
346+ if buf. kind ( ) != IFLA_INFO_KIND {
347+ return Err ( format ! (
348+ "failed to parse IFLA_INFO_KIND: NLA type is {}" ,
349+ buf. kind( )
350+ )
351+ . into ( ) ) ;
352+ }
353+ let s = parse_string ( buf. value ( ) )
354+ . context ( "invalid IFLA_INFO_KIND value" ) ?;
355+ Ok ( s. as_str ( ) . into ( ) )
350356 }
351357}
0 commit comments