feat: extism works
This commit is contained in:
23
__wasm/extism/extism_plugin/src/lib.rs
Normal file
23
__wasm/extism/extism_plugin/src/lib.rs
Normal 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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user