47 lines
1.5 KiB
Rust
Raw Normal View History

2021-11-22 11:28:30 -05:00
use crate::command_processor::*;
2024-03-02 23:49:12 -05:00
use crate::cursive_ui::CursiveUICallback;
use crate::interactive_ui::InteractiveUICallback;
2024-03-03 18:38:25 -05:00
use crate::io_read_write_ui::IOReadWriteUICallback;
2024-03-03 21:22:05 -05:00
use crate::log_viewer_ui::LogViewerUICallback;
2023-06-08 14:07:09 -04:00
use crate::tools::*;
2023-12-09 12:27:44 -05:00
use flexi_logger::writers::LogWriter;
2024-03-02 23:49:12 -05:00
use log::Level;
2024-03-02 23:49:12 -05:00
pub enum UICallback {
Cursive(CursiveUICallback),
Interactive(InteractiveUICallback),
2024-03-03 18:38:25 -05:00
IOReadWrite(IOReadWriteUICallback),
LogViewer(LogViewerUICallback),
2021-11-22 11:28:30 -05:00
}
2024-03-02 23:49:12 -05:00
pub trait UISender: Send {
fn clone_uisender(&self) -> Box<dyn UISender>;
fn as_logwriter(&self) -> Option<Box<dyn LogWriter>>;
2023-12-14 17:23:43 -05:00
2024-03-02 23:49:12 -05:00
fn display_string_dialog(&self, title: &str, text: &str, close_cb: UICallback);
fn quit(&self);
fn send_callback(&self, callback: UICallback);
fn set_attachment_state(
2023-06-08 14:07:09 -04:00
&mut self,
2024-03-02 23:49:12 -05:00
state: &str,
2023-06-08 14:07:09 -04:00
public_internet_ready: bool,
local_network_ready: bool,
2024-03-02 23:49:12 -05:00
);
fn set_network_status(
2023-06-08 14:07:09 -04:00
&mut self,
started: bool,
bps_down: u64,
bps_up: u64,
2024-03-02 23:49:12 -05:00
peers: Vec<json::JsonValue>,
);
fn set_config(&mut self, config: &json::JsonValue);
fn set_connection_state(&mut self, state: ConnectionState);
fn add_node_event(&self, log_color: Level, event: &str);
2024-03-03 18:38:25 -05:00
fn add_log_event(&self, log_color: Level, event: &str);
2023-12-09 12:27:44 -05:00
}
2024-03-02 23:49:12 -05:00
pub trait UI {
fn set_command_processor(&mut self, cmdproc: CommandProcessor);
fn run_async<'a>(&'a mut self) -> Pin<Box<dyn core::future::Future<Output = ()> + 'a>>;
2021-11-22 11:28:30 -05:00
}