reddit-magnet/src/actions/action.rs

27 lines
737 B
Rust

use crate::models::Magnet;
use crate::services::database::DatabaseService;
use async_trait::async_trait;
use color_eyre::eyre::Result;
/// Struct to hold the list of processed and failed magnets
pub struct ProcessedMagnets {
pub success: Vec<Magnet>,
pub failed: Vec<Magnet>,
}
/// Trait for actions that process magnet links
#[async_trait]
pub trait Action {
/// Return the name of the action
fn name() -> &'static str
where
Self: Sized;
fn get_name(&self) -> &'static str;
/// Process all unprocessed magnet links and return the list of processed magnets
async fn process_unprocessed_magnets(
&mut self,
db_service: &mut DatabaseService,
) -> Result<ProcessedMagnets>;
}