platform_module/
binding.rs1use platform_core::EventHandlerRegistry;
4use platform_runtime::{FunctionRegistry, RuntimeClient};
5use std::sync::Arc;
6
7#[derive(Debug, Clone, Default)]
8pub struct EventHandlerRegistrationContext {
9 runtime: Option<EventHandlerRuntimeContext>,
10}
11
12impl EventHandlerRegistrationContext {
13 #[must_use]
14 pub fn empty() -> Self {
15 Self::default()
16 }
17
18 #[must_use]
19 pub fn with_runtime(
20 runtime_client: RuntimeClient,
21 function_registry: Arc<FunctionRegistry>,
22 ) -> Self {
23 Self {
24 runtime: Some(EventHandlerRuntimeContext {
25 runtime_client,
26 function_registry,
27 }),
28 }
29 }
30
31 #[must_use]
32 pub fn runtime(&self) -> Option<&EventHandlerRuntimeContext> {
33 self.runtime.as_ref()
34 }
35}
36
37#[derive(Debug, Clone)]
38pub struct EventHandlerRuntimeContext {
39 pub runtime_client: RuntimeClient,
40 pub function_registry: Arc<FunctionRegistry>,
41}
42
43pub trait ModuleBinding: std::fmt::Debug + Send + Sync {
51 fn register_functions(&self, registry: &mut FunctionRegistry);
53
54 fn register_event_handlers(
56 &self,
57 registry: &mut EventHandlerRegistry,
58 context: &EventHandlerRegistrationContext,
59 );
60}