baby steps
parent
02db853f8c
commit
5d65aa5b42
|
|
@ -1 +1,8 @@
|
|||
/target
|
||||
|
||||
|
||||
# Added by cargo
|
||||
#
|
||||
# already existing elements were commented out
|
||||
|
||||
#/target
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -8,20 +8,20 @@ pub trait InputEngine {
|
|||
fn get(&mut self) -> Vec<char>;
|
||||
}
|
||||
|
||||
pub fn build_input_engine(cfg: &Engine) -> impl InputEngine {
|
||||
pub fn build_input_engine(cfg: &Engine) -> Box<dyn InputEngine> {
|
||||
match cfg.name.as_str() {
|
||||
"stdin" => {
|
||||
return InputEngineStdin{};
|
||||
return Box::new(InputEngineStdin{});
|
||||
},
|
||||
"kafka" => {
|
||||
return build_input_engine_kafka(&cfg).unwrap();
|
||||
return Box::new(build_input_engine_kafka(&cfg).unwrap());
|
||||
},
|
||||
"udp" => return build_input_engine_udp(&cfg).unwrap(),
|
||||
"device" => return build_input_engine_device(&cfg).unwrap(),
|
||||
"udp" => return Box::new(build_input_engine_udp(&cfg).unwrap()),
|
||||
"device" => return Box::new(build_input_engine_device(&cfg).unwrap()),
|
||||
_ => {},
|
||||
};
|
||||
assert!(false);
|
||||
InputEngineStdin{}
|
||||
Box::new(InputEngineStdin{})
|
||||
}
|
||||
|
||||
struct InputEngineDevice {
|
||||
|
|
@ -191,14 +191,14 @@ pub trait OutputEngine {
|
|||
fn put(&mut self, v: Vec<char>);
|
||||
}
|
||||
|
||||
pub fn build_output_engine(cfg: &Engine) -> impl OutputEngine {
|
||||
pub fn build_output_engine(cfg: &Engine) -> Box<dyn OutputEngine> {
|
||||
if cfg.name.as_str() == "stdout" {
|
||||
return OutputEngineStdout{};
|
||||
return Box::new(OutputEngineStdout{});
|
||||
} else if cfg.name.as_str() == "udp" {
|
||||
return build_output_engine_udp(&cfg).unwrap();
|
||||
return Box::new(build_output_engine_udp(&cfg).unwrap());
|
||||
}
|
||||
assert!(false);
|
||||
OutputEngineStdout{}
|
||||
Box::new(OutputEngineStdout{})
|
||||
}
|
||||
|
||||
struct OutputEngineStdout {}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use iced::{Alignment, Element, Application, Settings, Subscription, Theme, Comma
|
|||
|
||||
use crate::engine::OutputEngine;
|
||||
|
||||
pub fn main(outputEngine: &impl OutputEngine) -> iced::Result {
|
||||
pub fn main(outputEngine: &(impl OutputEngine + ?Sized)) -> iced::Result {
|
||||
let settings = Settings{
|
||||
flags: Flags {
|
||||
//outputEngine: outputEngine,
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@ mod config;
|
|||
mod engine;
|
||||
mod gui;
|
||||
|
||||
use crate::engine::{InputEngine, OutputEngine};
|
||||
|
||||
fn main() {
|
||||
let cfg = config::build_config().unwrap();
|
||||
if cfg.streams.input.engine.name == "gui" {
|
||||
let mut output_engine = engine::build_output_engine(&cfg.streams.output.engine);
|
||||
gui::main(&output_engine).unwrap();
|
||||
gui::main(&*output_engine).unwrap();
|
||||
} else {
|
||||
main_cli(cfg);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue