use super::stream::Event;
impl Event {
pub fn new(id: String, source: String, r#type: String, data: Vec<u8>) -> Self {
Self {
id,
source,
specversion: "1.0".into(),
r#type,
data,
..Default::default()
}
}
pub fn with_specversion(mut self, specversion: String) -> Self {
self.specversion = specversion;
self
}
pub fn with_optattrs(mut self, optattrs: std::collections::HashMap<String, String>) -> Self {
self.optattrs = optattrs;
self
}
pub fn with_datacontenttype(mut self, datacontenttype: String) -> Self {
self.optattrs.insert("datacontenttype".into(), datacontenttype);
self
}
pub fn get_datacontenttype(&self) -> Option<&String> {
self.optattrs.get("datacontenttype")
}
pub fn with_dataschema(mut self, dataschema: String) -> Self {
self.optattrs.insert("dataschema".into(), dataschema);
self
}
pub fn get_dataschema(&self) -> Option<&String> {
self.optattrs.get("dataschema")
}
pub fn with_subject(mut self, subject: String) -> Self {
self.optattrs.insert("subject".into(), subject);
self
}
pub fn get_subject(&self) -> Option<&String> {
self.optattrs.get("subject")
}
pub fn with_time(mut self, time: String) -> Self {
self.optattrs.insert("time".into(), time);
self
}
pub fn get_time(&self) -> Option<&String> {
self.optattrs.get("time")
}
pub fn with_extattr(mut self, key: String, val: String) -> Self {
self.optattrs.insert(key, val);
self
}
pub fn get_extattr(&self, key: &str) -> Option<&String> {
self.optattrs.get(key)
}
}