reddit-image-wall-rs/src/fetch/mod.rs

30 lines
682 B
Rust

use super::subprograms::*;
use std::collections::HashMap;
use threadpool::ThreadPool;
pub static SUBPROGRAM: Subprogram = Subprogram {
name: SUBPROGRAM_NAME,
wrapper,
};
pub static SUBPROGRAM_NAME: &str = "fetch";
fn wrapper<'a>(arg: &HashMap<String, String>) -> WrapperFnRet<'a> {
let mw = parse_from::<usize>(arg, &"max_workers".to_string(), &"16".to_string())?;
Ok(Box::new(FetchCallable { max_workers: mw }))
}
struct FetchCallable {
max_workers: usize,
}
impl SubprogramWithArguments for FetchCallable {
fn call(&self) -> Result<(), String> {
main(self.max_workers)
}
}
fn main(max_workers: usize) -> Result<(), String> {
Ok(())
}