Compare commits

..

6 Commits

Author SHA1 Message Date
88a7acd55d feat: Improved device conversion error message
All checks were successful
Build and deploy / build (push) Successful in 10m37s
Build and deploy / Deploy container (push) Has been skipped
2025-10-19 03:40:16 +02:00
3b7579878b feat: Use ActionCallback for schedule
This has two advantages:
- Each schedule entry can take either a single function or table of
  functions.
- We get a better type definition.
2025-10-19 03:40:16 +02:00
46c32c3605 refactor(config)!: Move scheduler out of device_manager
Due to changes made in mlua the new scheduler is much simpler. It also
had no real business being part of the device manager, so it has now been
moved to be part of the returned config.
2025-10-19 03:40:16 +02:00
d1e7988117 feat: Receive devices through config return 2025-10-19 03:40:15 +02:00
93b0a526b1 feat: Ensure consistent ordering device definitions 2025-10-19 03:40:15 +02:00
7bb5e65c1c feat: Generate definitions for config 2025-10-19 03:40:15 +02:00
2 changed files with 6 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ impl mlua::FromLua for Box<dyn Device> {
fn from_lua(value: mlua::Value, _lua: &mlua::Lua) -> mlua::Result<Self> { fn from_lua(value: mlua::Value, _lua: &mlua::Lua) -> mlua::Result<Self> {
match value { match value {
mlua::Value::UserData(ud) => { mlua::Value::UserData(ud) => {
let ud = if ud.is::<Box<dyn Device>>() { let ud = if ud.is::<Self>() {
ud ud
} else { } else {
ud.call_method::<_>("__box", ())? ud.call_method::<_>("__box", ())?
@@ -36,7 +36,10 @@ impl mlua::FromLua for Box<dyn Device> {
let b = ud.borrow::<Self>()?.clone(); let b = ud.borrow::<Self>()?.clone();
Ok(b) Ok(b)
} }
_ => Err(mlua::Error::RuntimeError("Expected user data".into())), _ => Err(mlua::Error::runtime(format!(
"Expected user data, instead found: {}",
value.type_name()
))),
} }
} }
} }

View File

@@ -32,7 +32,7 @@ fn config_definitions() -> String {
output += output +=
&FulfillmentConfig::generate_full().expect("FulfillmentConfig should have a definition"); &FulfillmentConfig::generate_full().expect("FulfillmentConfig should have a definition");
output += "\n"; output += "\n";
output += &Config::generate_full().expect("FulfillmentConfig should have a definition"); output += &Config::generate_full().expect("Config should have a definition");
output output
} }