diff --git a/src/event/attributes.rs b/src/event/attributes.rs index de7a0192..e8886286 100644 --- a/src/event/attributes.rs +++ b/src/event/attributes.rs @@ -234,6 +234,13 @@ impl Attributes { _ => self, } } + + pub fn iter(&self) -> impl Iterator { + match self { + Attributes::V03(a) => AttributesIter::IterV03(a.into_iter()), + Attributes::V10(a) => AttributesIter::IterV10(a.into_iter()), + } + } } #[cfg(not(target_arch = "wasm32"))] diff --git a/src/event/event.rs b/src/event/event.rs index f1888d0a..c7ab957b 100644 --- a/src/event/event.rs +++ b/src/event/event.rs @@ -1,6 +1,6 @@ use super::{ - AttributeValue, Attributes, AttributesIter, AttributesReader, AttributesV10, AttributesWriter, - Data, ExtensionValue, SpecVersion, + AttributeValue, Attributes, AttributesReader, AttributesV10, AttributesWriter, Data, + ExtensionValue, SpecVersion, }; use crate::event::attributes::DataAttributesWriter; use chrono::{DateTime, Utc}; @@ -82,10 +82,7 @@ impl Event { /// Returns an [`Iterator`] for all the available [CloudEvents Context attributes](https://github.com/cloudevents/spec/blob/master/spec.md#context-attributes), excluding extensions. /// This iterator does not contain the `data` field. pub fn iter_attributes(&self) -> impl Iterator { - match &self.attributes { - Attributes::V03(a) => AttributesIter::IterV03(a.into_iter()), - Attributes::V10(a) => AttributesIter::IterV10(a.into_iter()), - } + self.attributes.iter() } /// Get all the [extensions](https://github.com/cloudevents/spec/blob/master/spec.md#extension-context-attributes)