[−][src]Struct cloudevents::Event
Data structure that represents a CloudEvent.
It provides methods to get the attributes through AttributesReader
and write them through AttributesWriter.
It also provides methods to read and write the event data.
You can build events using super::EventBuilder
use cloudevents::Event; use cloudevents::event::AttributesReader; // Create an event using the Default trait let mut e = Event::default(); e.write_data( "application/json", serde_json::json!({"hello": "world"}) ); // Print the event id println!("Event id: {}", e.get_id()); // Get the event data let data: serde_json::Value = e.try_get_data().unwrap().unwrap(); println!("Event data: {}", data)
Implementations
impl Event[src]
pub fn remove_data(&mut self)[src]
Remove data, dataschema and datacontenttype from this Event
pub fn write_data(
&mut self,
datacontenttype: impl Into<String>,
data: impl Into<Data>
)[src]
&mut self,
datacontenttype: impl Into<String>,
data: impl Into<Data>
)
Write data into this Event with the specified datacontenttype.
use cloudevents::Event; use serde_json::json; use std::convert::Into; let mut e = Event::default(); e.write_data("application/json", json!({}))
pub fn write_data_with_schema(
&mut self,
datacontenttype: impl Into<String>,
dataschema: impl Into<Url>,
data: impl Into<Data>
)[src]
&mut self,
datacontenttype: impl Into<String>,
dataschema: impl Into<Url>,
data: impl Into<Data>
)
Write data into this Event with the specified datacontenttype and dataschema.
use cloudevents::Event; use serde_json::json; use std::convert::Into; use url::Url; let mut e = Event::default(); e.write_data_with_schema( "application/json", Url::parse("http://myapplication.com/schema").unwrap(), json!({}) )
pub fn get_data<T: Sized + From<Data>>(&self) -> Option<T>[src]
Get data from this Event
pub fn try_get_data<T: Sized + TryFrom<Data>>(
&self
) -> Result<Option<T>, T::Error>[src]
&self
) -> Result<Option<T>, T::Error>
Try to get data from this Event
pub fn into_data<T: Sized + TryFrom<Data>>(self) -> Result<Option<T>, T::Error>[src]
Transform this Event into the content of data
pub fn get_extension(&self, extension_name: &str) -> Option<&ExtensionValue>[src]
Get the extension named extension_name
pub fn get_extensions(&self) -> Vec<(&str, &ExtensionValue)>[src]
Get all the extensions
pub fn set_extension<'name, 'event: 'name>(
&'event mut self,
extension_name: &'name str,
extension_value: impl Into<ExtensionValue>
)[src]
&'event mut self,
extension_name: &'name str,
extension_value: impl Into<ExtensionValue>
)
Set the extension named extension_name with extension_value
pub fn remove_extension<'name, 'event: 'name>(
&'event mut self,
extension_name: &'name str
) -> Option<ExtensionValue>[src]
&'event mut self,
extension_name: &'name str
) -> Option<ExtensionValue>
Remove the extension named extension_name
Trait Implementations
impl AttributesReader for Event[src]
fn get_id(&self) -> &str[src]
fn get_source(&self) -> &Url[src]
fn get_specversion(&self) -> SpecVersion[src]
fn get_type(&self) -> &str[src]
fn get_datacontenttype(&self) -> Option<&str>[src]
fn get_dataschema(&self) -> Option<&Url>[src]
fn get_subject(&self) -> Option<&str>[src]
fn get_time(&self) -> Option<&DateTime<Utc>>[src]
impl AttributesWriter for Event[src]
fn set_id(&mut self, id: impl Into<String>)[src]
fn set_source(&mut self, source: impl Into<Url>)[src]
fn set_type(&mut self, ty: impl Into<String>)[src]
fn set_subject(&mut self, subject: Option<impl Into<String>>)[src]
fn set_time(&mut self, time: Option<impl Into<DateTime<Utc>>>)[src]
impl BinaryDeserializer for Event[src]
fn deserialize_binary<R: Sized, V: BinarySerializer<R>>(
self,
visitor: V
) -> Result<R>[src]
self,
visitor: V
) -> Result<R>
fn into_event(self) -> Result<Event>[src]
impl BinarySerializer<Event> for Event[src]
fn set_spec_version(self, spec_version: SpecVersion) -> Result<Self>[src]
fn set_attribute(self, name: &str, value: MessageAttributeValue) -> Result<Self>[src]
fn set_extension(self, name: &str, value: MessageAttributeValue) -> Result<Self>[src]
fn end_with_data(self, bytes: Vec<u8>) -> Result<Event>[src]
fn end(self) -> Result<Event>[src]
impl Clone for Event[src]
impl Debug for Event[src]
impl Default for Event[src]
impl<'de> Deserialize<'de> for Event[src]
fn deserialize<D>(
deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>, [src]
deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
impl PartialEq<Event> for Event[src]
impl Serialize for Event[src]
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer, [src]
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
impl StructuralPartialEq for Event[src]
impl StructuredDeserializer for Event[src]
fn deserialize_structured<R, V: StructuredSerializer<R>>(
self,
visitor: V
) -> Result<R>[src]
self,
visitor: V
) -> Result<R>
fn into_event(self) -> Result<Event>[src]
impl StructuredSerializer<Event> for Event[src]
Auto Trait Implementations
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnwindSafe for Event
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,