Skip to main content

DynEvent

Struct DynEvent 

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

A runtime-constructed Event. Use this when the event id or payload shape is only known at runtime (plugin runtimes, FFI, scripting hosts).

use coralstack_cmd_ipc::prelude::*;
use serde_json::json;

registry.emit(DynEvent::new(
    "plugin.say_hi",
    json!({ "greeting": "hello" }),
))?;

Implementations§

Source§

impl DynEvent

Source

pub fn new(id: impl Into<String>, payload: Value) -> Self

Build a new dynamic event with a runtime id and a JSON payload.

Source

pub fn schema(self, schema: Value) -> Self

Attach a JSON Schema advertising the payload shape.

Trait Implementations§

Source§

impl Event for DynEvent

Source§

const ID: &'static str = ""

Compile-time event identifier. Ignored when a value overrides id to return a runtime string (as DynEvent does). Read more
Source§

fn id(&self) -> &str

Instance-level id. Defaults to ID; DynEvent overrides this to return a runtime-owned id.
Source§

fn schema(&self) -> Option<Value>

Wire-level JSON Schema for the payload, if one is available. The #[event] macro overrides this with a schema derived from schemars.
Source§

impl Serialize for DynEvent

Source§

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

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.