crapify 0.1.0

Deep-fry your images, and other crimes against pixels.
use std::collections::HashMap;

use clap::{ArgMatches, Args, Command, FromArgMatches};
use image::DynamicImage;

use crate::error::CrapifyError;

pub trait Crapifier {
    type Args: Args + FromArgMatches;
    fn run(&self, img: DynamicImage, args: &Self::Args) -> Result<DynamicImage, CrapifyError>;
}

pub struct CrapifierEntry {
    pub name: &'static str,
    pub augment_command: fn(Command) -> Command,
    pub run: fn(DynamicImage, &ArgMatches) -> Result<DynamicImage, CrapifyError>,
}

inventory::collect!(CrapifierEntry);

pub fn registry() -> HashMap<&'static str, &'static CrapifierEntry> {
    inventory::iter::<CrapifierEntry>
        .into_iter()
        .map(|e| (e.name, e))
        .collect()
}