feat: extism works

This commit is contained in:
2022-12-04 15:00:28 +08:00
parent 78561aec5b
commit 1098220058
6 changed files with 185 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
use extism_pdk::*;
use serde::Serialize;
const VOWELS: &[char] = &['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U'];
#[derive(Serialize)]
struct TestOutput {
pub count: i32,
}
#[plugin_fn]
pub fn count_vowels(input: String) -> FnResult<Json<TestOutput>> {
let mut count = 0;
for ch in input.chars() {
if VOWELS.contains(&ch) {
count += 1;
}
}
let output = TestOutput { count };
Ok(Json(output))
}