Mountain/Track/Effect/
MappedEffectType.rs

1//! # MappedEffect (Track)
2//!
3//! ## RESPONSIBILITIES
4//!
5//! This module defines the MappedEffect type alias, which is the type-erased
6//! unit of work that the dispatch logic can execute.
7//!
8//! ## ARCHITECTURAL ROLE
9//!
10//! MappedEffect serves as the **effect abstraction** in Track's dispatch
11//! system:
12//!
13//! ```text
14//! Dispatch Logic ──► MappedEffect (Boxed Closure) ──► ApplicationRunTime Execution
15//! ```
16//!
17//! ## KEY COMPONENTS
18//!
19//! - **MappedEffect**: Type alias for boxed async closure signature
20//!
21//! ## ERROR HANDLING
22//!
23//! - All effects return Result<Value, String> for IPC compatibility
24//!
25//! ## LOGGING
26//!
27//! - Logging is handled by individual effect implementations
28//!
29//! ## PERFORMANCE CONSIDERATIONS
30//!
31//! - Boxed closure allocation is lightweight
32//! - Async operations avoid blocking
33//!
34//! ## TODO
35//!
36//! - [ ] Consider implementing an effect pool to cache frequently created
37//!   effects
38
39use std::{future::Future, pin::Pin, sync::Arc};
40
41use serde_json::Value;
42
43use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
44
45/// A type alias for a boxed, runnable effect. This is the "type-erased" unit of
46/// work that the dispatch logic can execute.
47pub type MappedEffect =
48	Box<dyn FnOnce(Arc<ApplicationRunTime>) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send>> + Send>;