9
crates/cuddle-actions-api/Cargo.toml
Normal file
9
crates/cuddle-actions-api/Cargo.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "cuddle-actions-api"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
cuddle-lazy.workspace = true
|
||||
serde.workspace = true
|
||||
anyhow.workspace = true
|
30
crates/cuddle-actions-api/src/lib.rs
Normal file
30
crates/cuddle-actions-api/src/lib.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use cuddle_lazy::LazyResolve;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ExecutableActions {
|
||||
pub actions: Vec<ExecutableAction>,
|
||||
}
|
||||
|
||||
pub struct ExecutableAction {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub flags: BTreeMap<String, ExecutableActionFlag>,
|
||||
pub call_fn: LazyResolve,
|
||||
}
|
||||
|
||||
impl ExecutableAction {
|
||||
pub async fn call(&self) -> anyhow::Result<()> {
|
||||
self.call_fn.call().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum ExecutableActionFlag {
|
||||
String,
|
||||
Bool,
|
||||
}
|
Reference in New Issue
Block a user