Add iter() in cloudevents::event::Attributes (#89)
* Add iter in Attributes Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Removed bad import Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
This commit is contained in:
parent
fbadb3300a
commit
1858a1caa5
|
@ -243,6 +243,13 @@ impl Attributes {
|
||||||
_ => self,
|
_ => self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn iter(&self) -> impl Iterator<Item = (&str, AttributeValue)> {
|
||||||
|
match self {
|
||||||
|
Attributes::V03(a) => AttributesIter::IterV03(a.into_iter()),
|
||||||
|
Attributes::V10(a) => AttributesIter::IterV10(a.into_iter()),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::{
|
use super::{
|
||||||
AttributeValue, Attributes, AttributesIter, AttributesReader, AttributesV10, AttributesWriter,
|
AttributeValue, Attributes, AttributesReader, AttributesV10, AttributesWriter, Data,
|
||||||
Data, ExtensionValue, SpecVersion,
|
ExtensionValue, SpecVersion,
|
||||||
};
|
};
|
||||||
use crate::event::attributes::DataAttributesWriter;
|
use crate::event::attributes::DataAttributesWriter;
|
||||||
use chrono::{DateTime, Utc};
|
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.
|
/// 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.
|
/// This iterator does not contain the `data` field.
|
||||||
pub fn iter_attributes(&self) -> impl Iterator<Item = (&str, AttributeValue)> {
|
pub fn iter_attributes(&self) -> impl Iterator<Item = (&str, AttributeValue)> {
|
||||||
match &self.attributes {
|
self.attributes.iter()
|
||||||
Attributes::V03(a) => AttributesIter::IterV03(a.into_iter()),
|
|
||||||
Attributes::V10(a) => AttributesIter::IterV10(a.into_iter()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get all the [extensions](https://github.com/cloudevents/spec/blob/master/spec.md#extension-context-attributes)
|
/// Get all the [extensions](https://github.com/cloudevents/spec/blob/master/spec.md#extension-context-attributes)
|
||||||
|
|
Loading…
Reference in New Issue