pub enum EventData {
Json(Value),
Protobuf(Vec<u8>),
}Expand description
Event payload data supporting multiple serialization formats.
EventData provides flexibility in how you store event payloads:
- JSON for human-readable, schema-flexible events
- Protocol Buffers for compact, strongly-typed events
§Examples
use eventuali_core::EventData;
use serde_json::json;
// JSON event data
let json_data = EventData::from_json(&json!({
"user_id": "123",
"action": "login"
})).unwrap();
// Protocol Buffer event data
let proto_data = EventData::Protobuf(vec![1, 2, 3, 4]);Variants§
Implementations§
Source§impl EventData
impl EventData
pub fn from_json<T: Serialize>(value: &T) -> Result<Self>
pub fn to_json<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
pub fn from_protobuf(data: Vec<u8>) -> Self
pub fn to_protobuf(&self) -> Result<&[u8]>
pub fn from_protobuf_message<T: Message>(message: &T) -> Result<Self>
pub fn to_protobuf_message<T: Message + Default>(&self) -> Result<T>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for EventData
impl<'de> Deserialize<'de> for EventData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for EventData
Auto Trait Implementations§
impl Freeze for EventData
impl RefUnwindSafe for EventData
impl Send for EventData
impl Sync for EventData
impl Unpin for EventData
impl UnwindSafe for EventData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more