// config.reef — TOML service definition parser // // Parses /etc/zyginit.d/*.toml service definitions into ServiceDef structs. // Uses Reef's built-in TOML parser: import encoding.toml // // This module should be implemented first — it has no illumos dependencies // and can be tested on any platform. import encoding.toml import io.fs // Service types enum ServiceType { Daemon, // long-running process, restarted on exit Oneshot, // runs once, considered "started" after exit 0 Transient, // runs once, not tracked after exit } // Restart policy enum RestartPolicy { Always, OnFailure, Never, } // Stop method enum StopMethod { Contract, // signal all processes in contract (default) Exec, // run a stop command } // Service definition — parsed from TOML struct ServiceDef { name: String, description: String, service_type: ServiceType, // exec start_cmd: String, stop_cmd: Option, // stop stop_method: StopMethod, stop_signal: String, // "TERM", "HUP", etc. stop_timeout: i32, // seconds // dependencies requires: Vec, // hard dependencies — must be running after: Vec, // ordering — start after these, but don't require // contract contract_param: Vec, contract_fatal: Vec, // restart restart_policy: RestartPolicy, restart_delay: i32, // seconds max_retries: i32, // -1 = unlimited } // Parse a single TOML file into a ServiceDef fn parse_service(path: String) -> Result { // TODO: implement // 1. Read file contents // 2. Parse TOML // 3. Extract fields with defaults // 4. Validate required fields Err("not yet implemented") } // Scan /etc/zyginit.d/enabled.d/ and return list of enabled service paths fn scan_enabled(config_dir: String) -> Result, String> { // TODO: implement // 1. Read symlinks in enabled.d/ // 2. Resolve each to its .toml file // 3. Return list of absolute paths Err("not yet implemented") } // Load all enabled services fn load_enabled_services(config_dir: String) -> Result, String> { // TODO: implement // 1. scan_enabled() // 2. parse_service() for each // 3. Return Vec of ServiceDefs Err("not yet implemented") }