parent
aefceda628
commit
6520cc65a3
8 changed files with 715 additions and 481 deletions
src/fetchers
|
@ -1,9 +1,31 @@
|
|||
use async_trait::async_trait;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use strum_macros::Display;
|
||||
use crate::fetchers::Fetcher::Jnc;
|
||||
use crate::fetchers::jnovel::JNovelFetcher;
|
||||
use crate::lemmy::{PostInfo};
|
||||
|
||||
pub mod jnovel;
|
||||
|
||||
#[async_trait]
|
||||
pub(crate) trait Fetcher {
|
||||
type Return;
|
||||
async fn check_feed(&self) -> Result<Vec<Self::Return>, ()>;
|
||||
pub(crate) trait FetcherTrait {
|
||||
fn new() -> Self where Self: Sized;
|
||||
async fn check_feed(&self) -> Result<Vec<PostInfo>, ()>;
|
||||
}
|
||||
|
||||
impl Fetcher {
|
||||
pub(crate) async fn check_feed(&self) -> Result<Vec<PostInfo>, ()> {
|
||||
match self {
|
||||
Jnc(fetcher) => fetcher.check_feed().await,
|
||||
/*default => {
|
||||
let err_msg = format!("Fetcher {default} is not implemented");
|
||||
error!(err_msg);
|
||||
Err(())
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Clone, Display)]
|
||||
pub(crate) enum Fetcher {
|
||||
#[serde(rename = "jnc")]
|
||||
Jnc(JNovelFetcher)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue