use anyhow::anyhow; use async_trait::async_trait; use crate::config::Config; use crate::vault::VaultRef; pub mod c1; pub mod c2; #[async_trait] pub trait Challenge where Self: Sized, { fn new(config: Config, vault: VaultRef) -> Self; fn hints() -> Vec; fn solution() -> String; async fn serve(self) -> anyhow::Result<()>; } pub async fn select_and_start(index: u16, config: Config, vault: VaultRef) -> anyhow::Result<()> { match index { 1 => c1::C1::new(config, vault).serve().await?, 2 => c2::C2::new(config, vault).serve().await?, _ => { return Err(anyhow!( "no challenge with index {index} does currently exist" )) } } Ok(()) }