48 lines
1.3 KiB
Rust
48 lines
1.3 KiB
Rust
use crate::app::Action;
|
|
use tokio::sync::mpsc::{self, error::SendError};
|
|
|
|
// TODO: Put this somewhere closer to the procedural macro definitions
|
|
pub trait Component<T> {
|
|
fn handle_action(
|
|
&mut self,
|
|
action: T,
|
|
tx: &'static mpsc::UnboundedSender<Action>,
|
|
) -> Result<(), SendError<Action>>;
|
|
}
|
|
|
|
#[allow(unused_macros)]
|
|
#[macro_export]
|
|
macro_rules! status_info {
|
|
($action_tx:expr, $text:expr $(, $args:expr)*) => {
|
|
$action_tx.send(
|
|
crate::app::GlobalAction::ShowStatMsg(
|
|
crate::app::StatusMessage::Info(format!($text, $($args)*)))
|
|
.into(),
|
|
)
|
|
};
|
|
}
|
|
|
|
#[allow(unused_macros)]
|
|
#[macro_export]
|
|
macro_rules! status_warn {
|
|
($action_tx:expr, $text:expr $(, $args:expr)*) => {
|
|
$action_tx.send(
|
|
crate::app::GlobalAction::ShowStatMsg(
|
|
crate::app::StatusMessage::Info(format!($text, $($args)*)))
|
|
.into(),
|
|
)
|
|
};
|
|
}
|
|
|
|
#[allow(unused_macros)]
|
|
#[macro_export]
|
|
macro_rules! status_error {
|
|
($action_tx:expr, $text:expr $(, $args:expr)*) => {
|
|
$action_tx.send(
|
|
crate::app::GlobalAction::ShowStatMsg(
|
|
crate::app::StatusMessage::Info(format!($text, $($args)*)))
|
|
.into(),
|
|
)
|
|
};
|
|
}
|