Skip to main content

datex_core/datex_registry/
module_registry.rs

1use crate::{
2    datex_registry::registry_collect, prelude::*,
3    runtime::cache::shared_references_cache::SharedReferencesCache,
4    values::core_values::map::Map,
5};
6
7#[derive(Debug)]
8pub struct DatexModuleRegistration {
9    pub name: &'static str,
10    pub create_module: fn(memory: &mut SharedReferencesCache) -> Map,
11}
12
13registry_collect!(
14    DatexModuleRegistration,
15    DATEX_MODULE_REGISTRATIONS,
16    all_datex_module_registrations
17);
18
19pub fn get_all_modules(
20    memory: &mut SharedReferencesCache,
21) -> Vec<(String, Map)> {
22    all_datex_module_registrations()
23        .map(|registration| {
24            (
25                registration.name.to_string(),
26                (registration.create_module)(memory),
27            )
28        })
29        .collect()
30}