use crate::csaf::traits::util::{impl_optional_str_field_getter, impl_str_iter_field_getter};
use crate::csaf_traits::ContentTrait;
use crate::schema::csaf2_0::schema::Score as Score20;
use crate::schema::csaf2_1::schema::{Content as Content21, Metric as Metric21};
pub trait MetricTrait {
type ContentType: ContentTrait;
fn get_products(&self) -> impl Iterator<Item = &str> + '_;
fn get_content(&self) -> &Self::ContentType;
fn get_source(&self) -> Option<&str>;
}
impl MetricTrait for Score20 {
type ContentType = Score20;
impl_str_iter_field_getter!(get_products, products);
fn get_content(&self) -> &Self::ContentType {
self
}
fn get_source(&self) -> Option<&str> {
None
}
}
impl MetricTrait for Metric21 {
type ContentType = Content21;
impl_str_iter_field_getter!(get_products, products);
fn get_content(&self) -> &Self::ContentType {
&self.content
}
impl_optional_str_field_getter!(get_source, source);
}