Move stuff to app/common.rs
This commit is contained in:
parent
b496edf404
commit
dd2d19ee13
42
src/app.rs
42
src/app.rs
@ -11,8 +11,10 @@ use tokio::{
|
||||
time::sleep,
|
||||
};
|
||||
|
||||
use crate::literature::{
|
||||
Publication, SnowballingHistory, get_publication_by_id,
|
||||
use crate::{
|
||||
app::common::Component,
|
||||
literature::{Publication, SnowballingHistory, get_publication_by_id},
|
||||
status_error, status_info,
|
||||
};
|
||||
|
||||
use seeding::{SeedingAction, SeedingComponent};
|
||||
@ -55,14 +57,6 @@ pub enum Action {
|
||||
Global(GlobalAction),
|
||||
}
|
||||
|
||||
pub trait Component<T> {
|
||||
fn handle_action(
|
||||
&mut self,
|
||||
action: T,
|
||||
tx: &mpsc::UnboundedSender<Action>,
|
||||
) -> Result<(), SendError<Action>>;
|
||||
}
|
||||
|
||||
impl From<GlobalAction> for Action {
|
||||
fn from(action: GlobalAction) -> Self {
|
||||
Action::Global(action)
|
||||
@ -109,34 +103,6 @@ pub struct App {
|
||||
pub action_tx: &'static mpsc::UnboundedSender<Action>,
|
||||
}
|
||||
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! status_info {
|
||||
($action_tx:expr, $text:expr, $($args:expr)*) => {
|
||||
$action_tx.send(
|
||||
GlobalAction::ShowStatusMessage(StatusMessage::Info(format!($text, $($args)*)))
|
||||
.into(),
|
||||
)
|
||||
};
|
||||
}
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! status_warn {
|
||||
($action_tx:expr, $text:expr, $($args:expr)*) => {
|
||||
$action_tx.send(
|
||||
GlobalAction::ShowStatusMessage(StatusMessage::Warning(format!($text, $($args)*)))
|
||||
.into(),
|
||||
)
|
||||
};
|
||||
}
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! status_error {
|
||||
($action_tx:expr, $text:expr $(, $args:expr)*) => {
|
||||
$action_tx.send(
|
||||
GlobalAction::ShowStatusMessage(StatusMessage::Error(format!($text, $($args)*)))
|
||||
.into(),
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Implement moving through steps and iterations (populating pending papers)
|
||||
// TODO: Implement exclusion and inclusion of papers (e.g., X and Y chars)
|
||||
// TODO: Implement possibility of pushing excluded papers back into pending
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
use tokio::sync::mpsc::{self, error::SendError};
|
||||
|
||||
use crate::app::Action;
|
||||
|
||||
#[allow(unused_macros)]
|
||||
#[macro_export]
|
||||
macro_rules! status_info {
|
||||
($action_tx:expr, $text:expr, $($args:expr)*) => {
|
||||
$action_tx.send(
|
||||
GlobalAction::ShowStatusMessage(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(
|
||||
GlobalAction::ShowStatusMessage(StatusMessage::Warning(format!($text, $($args)*)))
|
||||
.into(),
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unused_macros)]
|
||||
#[macro_export]
|
||||
macro_rules! status_error {
|
||||
($action_tx:expr, $text:expr $(, $args:expr)*) => {
|
||||
$action_tx.send(
|
||||
GlobalAction::ShowStatusMessage(StatusMessage::Error(format!($text, $($args)*)))
|
||||
.into(),
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
pub trait Component<T> {
|
||||
fn handle_action(
|
||||
&mut self,
|
||||
action: T,
|
||||
tx: &mpsc::UnboundedSender<Action>,
|
||||
) -> Result<(), SendError<Action>>;
|
||||
}
|
||||
@ -1,10 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::mpsc::{self, error::SendError};
|
||||
|
||||
use crate::{
|
||||
app::{Action, Component},
|
||||
literature::Publication,
|
||||
};
|
||||
use crate::{app::Action, app::common::Component, literature::Publication};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum SeedingAction {
|
||||
|
||||
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::sync::mpsc::error::SendError;
|
||||
|
||||
use crate::app::{Action, Component};
|
||||
use crate::app::{Action, common::Component};
|
||||
use crate::literature::Publication;
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, PartialEq)]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user