From 502ea114a6a6c449257a183b91f25a2228234314 Mon Sep 17 00:00:00 2001 From: prplV Date: Tue, 22 Apr 2025 11:18:36 -0400 Subject: [PATCH] debug + casting --- noxis-rs/src/options/structs.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/noxis-rs/src/options/structs.rs b/noxis-rs/src/options/structs.rs index 5951fd8..7d4d81b 100644 --- a/noxis-rs/src/options/structs.rs +++ b/noxis-rs/src/options/structs.rs @@ -8,6 +8,7 @@ pub enum DependencyType { Service, } +#[derive(Debug)] pub enum ServiceState { Ok, Unavailable @@ -49,17 +50,24 @@ impl<'a> FileTriggerType { } } +#[derive(Debug)] pub enum Triggers<'a> { File{ on_change: &'a str, on_delete: &'a str }, - Service(&'a str), + Service{on_lost: &'a str, wait: u32}, } impl<'a> Triggers<'a> { pub fn new_file(on_change: &'a str, on_delete: &'a str) -> Triggers<'a> { Triggers::File { on_change, on_delete } } - pub fn new_service(on_lost: &'a str) -> Triggers<'a> { - Triggers::Service(on_lost) + pub fn new_service(on_lost: &'a str, wait_time: u32) -> Triggers<'a> { + Triggers::Service{on_lost, wait: wait_time} + } + pub fn to_service_negative_event(&'a self, service_name: &'a str) -> Option> { + if let Triggers::Service { on_lost, .. } = self { + return Some(Events::Negative(NegativeOutcomes::ServiceIsUnreachable(service_name, DependencyType::Service, &on_lost))) + } + None } } @@ -92,7 +100,7 @@ pub enum NegativeOutcomes<'a> { } pub trait ProcessUnit<'a> { - fn process(&mut self) -> impl std::future::Future + Send; + fn process(&'a mut self) -> impl std::future::Future + Send; } /// # an Error enum (next will be deleted and replaced)