Skip to main content

EventKind

Struct EventKind 

Source
pub struct EventKind { /* private fields */ }
Expand description

Domain-neutral event identity and structured fields.

The type tag and flattened field layout deliberately preserve the wire shape used by earlier concrete event variants. Domain crates and runtime compatibility modules own typed payloads and encode them through Self::from_payload; this crate does not own their vocabulary.

Implementations§

Source§

impl EventKind

Source

pub fn from_fields( event_type: impl Into<String>, fields: BTreeMap<String, Value>, ) -> Result<EventKind, EventKindError>

Builds an event record from an explicit type and flattened fields.

§Errors

Returns an error when the type is empty or the fields contain the reserved type key.

Source

pub fn from_payload<T>( event_type: impl Into<String>, payload: &T, ) -> Result<EventKind, EventKindError>
where T: Serialize,

Serializes a typed domain payload into an event record.

§Errors

Returns an error when serialization fails, the payload is not an object, the type is empty, or the payload contains the reserved type key.

Source

pub fn plugin( plugin: impl Into<String>, event_type: impl Into<String>, ) -> EventKind

Constructs the compatibility wire identity for a plugin event.

Source

pub fn event_type(&self) -> &str

Source

pub fn is_type(&self, event_type: &str) -> bool

Source

pub fn fields(&self) -> BTreeMap<String, Value>

Source

pub fn field(&self, name: &str) -> Option<Value>

Source

pub fn set_field<T>( &mut self, name: &str, value: &T, ) -> Result<(), EventKindError>
where T: Serialize,

Replaces one existing field with a serializable value.

§Errors

Returns an error when the field is absent or the value cannot be represented as structured JSON data.

Source

pub fn decode_payload<T>(&self) -> Result<T, EventKindError>

Decodes all flattened fields into a domain-owned payload type.

§Errors

Returns an error when the fields do not deserialize as T.

Source

pub fn decode_field<T>(&self, name: &str) -> Result<T, EventKindError>

Decodes one named field.

§Errors

Returns an error when the field is absent or does not deserialize as T.

Source

pub fn plugin_identity(&self) -> Option<(&str, &str)>

Source

pub fn qualified_event_type(&self) -> String

Returns the stable, display-oriented type identity for this event.

Built-in event kinds retain the same snake-case labels returned by Self::event_type. Plugin events are qualified with their registered plugin name and event type, separated by a dot. The two plugin-provided components are preserved as registered; no case folding or additional normalization is applied.

Trait Implementations§

Source§

impl Clone for EventKind

Source§

fn clone(&self) -> EventKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EventKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for EventKind

Source§

fn deserialize<D>( deserializer: D, ) -> Result<EventKind, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for EventKind

Source§

impl PartialEq for EventKind

Source§

fn eq(&self, other: &EventKind) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for EventKind

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.