From c565171593c2c3683bb267e191eb7e1a45accd9f Mon Sep 17 00:00:00 2001 From: Luuk Hendriks Date: Mon, 26 Feb 2024 16:47:46 +0100 Subject: [PATCH] Provide default fn impls in FromAttribute trait --- src/bgp/path_attributes.rs | 16 +++++++++++----- src/bgp/workshop/route.rs | 34 ++++------------------------------ 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/src/bgp/path_attributes.rs b/src/bgp/path_attributes.rs index 40fd3a1d..386fe830 100644 --- a/src/bgp/path_attributes.rs +++ b/src/bgp/path_attributes.rs @@ -341,15 +341,21 @@ impl PaMap { pub trait FromAttribute { - fn from_attribute(value: PathAttribute) -> Option + fn from_attribute(_value: PathAttribute) -> Option where - Self: Sized; - fn attribute_type() -> Option; + Self: Sized { + None + } + + fn attribute_type() -> Option { + None + } + } impl From for PaMap { - fn from(value: AttributesMap) -> Self { - Self { attributes: value } + fn from(attributes: AttributesMap) -> Self { + Self { attributes } } } diff --git a/src/bgp/workshop/route.rs b/src/bgp/workshop/route.rs index 038b55c7..5dcb0ac3 100644 --- a/src/bgp/workshop/route.rs +++ b/src/bgp/workshop/route.rs @@ -13,7 +13,7 @@ use crate::bgp::{ message::{nlri::Nlri, update_builder::StandardCommunitiesList}, path_attributes::{ ExtendedCommunitiesList, Ipv6ExtendedCommunitiesList, - LargeCommunitiesList, PathAttribute, PathAttributeType, + LargeCommunitiesList, PathAttribute, }, }; @@ -241,29 +241,11 @@ impl WorkshopAttribute for Vec { } } -impl FromAttribute for Vec { - fn from_attribute(_value: PathAttribute) -> Option { - None - } - - fn attribute_type() -> Option { - None - } -} +impl FromAttribute for Vec { } //------------ NlriWorkshop -------------------------------------------------- -impl FromAttribute for crate::bgp::message::nlri::Nlri> { - fn from_attribute(_value: PathAttribute) -> Option - where - Self: Sized { - None - } - - fn attribute_type() -> Option { - None - } -} +impl FromAttribute for crate::bgp::message::nlri::Nlri> { } impl WorkshopAttribute for crate::bgp::message::nlri::Nlri> { fn retrieve(attrs: &PaMap) -> Option @@ -286,15 +268,7 @@ impl WorkshopAttribute for crate::bgp::message::nlri::Nlri Option { - None - } - - fn from_attribute(_value: PathAttribute) -> Option { - None - } -} +impl FromAttribute for crate::bgp::types::NextHop { } impl WorkshopAttribute for crate::bgp::types::NextHop { fn retrieve(attrs: &PaMap) -> Option {