I have a UI application written in iced, which performs various operation. To launch the UI I'm using run() method: UpdateDriver::run(Settings::default())
and currently this returns the exit code of type iced::Result
and type of result is pub type Result = Result<(), Error>;
, but I want the application to return custom exit code of type u8
based on the operation performed.
Ex: 0(success), 1(failure), 3(reboot) etc.
I need help on how to do that.
Current WorkFlow:
fn launch_ui_mode() -> iced::Result {
UpdateDriver::run(Settings::default())
}
Expectation:
fn launch_ui_mode() -> u8 {
UpdateDriver::run(Settings::default())
}
Main Function:
fn main() -> ExitCode {
let retcode: u8;
let exec_type = get_execution_mode();
if exec_mode == UI{
retcode = launch_ui_mode(); //This is iced::result type, I need u8 type
}
else{
retcode = launch_cli_mode();
}
return ExitCode::from(retcode);
}
My application runs in both CLI and UI mode, for CLI mode I'm directly returning the u8
type exit code, need to implement that for UI mode too.
So if something like this is not possible, what is the other way to return the exit-code from the UI. Should I add the global variable to store the exit code in UI part of code? Will it be safe?