wooly-vault/src/challenge/mod.rs
PlexSheep b96634af7c
All checks were successful
cargo devel CI / cargo CI (push) Successful in 1m37s
feat: proper cli
2024-09-06 18:00:51 +02:00

32 lines
747 B
Rust

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<String>;
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(())
}