intuicio_frontend_simpleton/library/
mod.rs1pub mod array;
2pub mod bytes;
3pub mod closure;
4#[cfg(feature = "console")]
5pub mod console;
6pub mod debug;
7pub mod event;
8#[cfg(feature = "ffi")]
9pub mod ffi;
10#[cfg(feature = "fs")]
11pub mod fs;
12pub mod iter;
13#[cfg(feature = "jobs")]
14pub mod jobs;
15pub mod json;
16pub mod map;
17pub mod math;
18#[cfg(feature = "net")]
19pub mod net;
20#[cfg(feature = "process")]
21pub mod process;
22pub mod promise;
23pub mod reflect;
24pub mod text;
25pub mod toml;
26
27use crate::{Map, Reference};
28use intuicio_core::{object::Object, registry::Registry, types::TypeQuery};
29
30pub struct ObjectBuilder {
31 name: String,
32 module_name: String,
33 fields: Map,
34}
35
36impl ObjectBuilder {
37 pub fn new(name: impl ToString, module_name: impl ToString) -> Self {
38 Self {
39 name: name.to_string(),
40 module_name: module_name.to_string(),
41 fields: Map::new(),
42 }
43 }
44
45 pub fn field(mut self, name: impl ToString, value: Reference) -> Self {
46 self.fields.insert(name.to_string(), value);
47 self
48 }
49
50 pub fn build(self, registry: &Registry) -> Object {
51 let type_ = registry
52 .find_type(TypeQuery {
53 name: Some(self.name.into()),
54 module_name: Some(self.module_name.into()),
55 ..Default::default()
56 })
57 .unwrap();
58 let mut result = Object::new(type_);
59 for (key, value) in self.fields {
60 *result.write_field::<Reference>(&key).unwrap() = value;
61 }
62 result
63 }
64}
65
66pub fn install(registry: &mut Registry) {
67 reflect::install(registry);
68 math::install(registry);
69 text::install(registry);
70 array::install(registry);
71 map::install(registry);
72 #[cfg(feature = "console")]
73 console::install(registry);
74 #[cfg(feature = "fs")]
75 fs::install(registry);
76 #[cfg(feature = "ffi")]
77 ffi::install(registry);
78 #[cfg(feature = "process")]
79 process::install(registry);
80 #[cfg(feature = "net")]
81 net::install(registry);
82 bytes::install(registry);
83 json::install(registry);
84 toml::install(registry);
85 debug::install(registry);
86 closure::install(registry);
87 iter::install(registry);
88 promise::install(registry);
89 event::install(registry);
90 #[cfg(feature = "jobs")]
91 jobs::install(registry);
92}