refactor(config)!: Setup for expanding lua config return

Moves the application config out of automation_lib and sets up the
config return type for further expansion.
This commit is contained in:
2025-10-17 02:41:03 +02:00
parent a95574b731
commit ba818c6b60
4 changed files with 43 additions and 40 deletions

View File

@@ -1,9 +1,10 @@
use std::collections::HashMap;
use std::net::{Ipv4Addr, SocketAddr};
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Config {
pub struct Setup {
#[serde(default = "default_entrypoint")]
pub entrypoint: String,
#[serde(default)]
@@ -15,3 +16,30 @@ pub struct Config {
fn default_entrypoint() -> String {
"./config.lua".into()
}
#[derive(Debug, Deserialize)]
pub struct FulfillmentConfig {
pub openid_url: String,
#[serde(default = "default_fulfillment_ip")]
pub ip: Ipv4Addr,
#[serde(default = "default_fulfillment_port")]
pub port: u16,
}
#[derive(Debug, Deserialize)]
pub struct Config {
pub fulfillment: FulfillmentConfig,
}
impl From<FulfillmentConfig> for SocketAddr {
fn from(fulfillment: FulfillmentConfig) -> Self {
(fulfillment.ip, fulfillment.port).into()
}
}
fn default_fulfillment_ip() -> Ipv4Addr {
[0, 0, 0, 0].into()
}
fn default_fulfillment_port() -> u16 {
7878
}