use platform_core::EventHandlerRegistry;
use platform_runtime::{FunctionRegistry, RuntimeClient};
use std::sync::Arc;
#[derive(Debug, Clone, Default)]
pub struct EventHandlerRegistrationContext {
runtime: Option<EventHandlerRuntimeContext>,
}
impl EventHandlerRegistrationContext {
#[must_use]
pub fn empty() -> Self {
Self::default()
}
#[must_use]
pub fn with_runtime(
runtime_client: RuntimeClient,
function_registry: Arc<FunctionRegistry>,
) -> Self {
Self {
runtime: Some(EventHandlerRuntimeContext {
runtime_client,
function_registry,
}),
}
}
#[must_use]
pub fn runtime(&self) -> Option<&EventHandlerRuntimeContext> {
self.runtime.as_ref()
}
}
#[derive(Debug, Clone)]
pub struct EventHandlerRuntimeContext {
pub runtime_client: RuntimeClient,
pub function_registry: Arc<FunctionRegistry>,
}
pub trait ModuleBinding: std::fmt::Debug + Send + Sync {
fn register_functions(&self, registry: &mut FunctionRegistry);
fn register_event_handlers(
&self,
registry: &mut EventHandlerRegistry,
context: &EventHandlerRegistrationContext,
);
}