arhivach-downloader

Download arhivach.vc threads
git clone https://git.ea.contact/arhivach-downloader
Log | Files | Refs | README

mod.rs (790B)


      1 pub mod html;
      2 
      3 use super::{config::Config, post::Post};
      4 use crate::error::{Error, Result};
      5 
      6 use std::str::FromStr;
      7 
      8 #[derive(Clone)]
      9 pub enum ExporterKind {
     10     Html(html::HtmlExporter),
     11 }
     12 
     13 pub trait Exporter {
     14     fn export(&self, posts: &[Post], config: &Config) -> Result<()>;
     15 }
     16 
     17 impl Exporter for ExporterKind {
     18     fn export(&self, posts: &[Post], config: &Config) -> Result<()> {
     19         match self {
     20             ExporterKind::Html(html) => html.export(posts, config),
     21         }
     22     }
     23 }
     24 
     25 impl FromStr for ExporterKind {
     26     type Err = Error;
     27 
     28     fn from_str(s: &str) -> Result<ExporterKind> {
     29         match s.to_lowercase().as_str() {
     30             "html" => Ok(ExporterKind::Html(html::HtmlExporter {})),
     31             _ => Err(Error::UnknownExporter(s.to_string())),
     32         }
     33     }
     34 }