Write plugin to be used in app

This commit is contained in:
Fabian Schmidt 2024-01-12 15:54:39 +01:00
parent c7fde2a87e
commit dfc8cf908d

View File

@ -4,3 +4,15 @@ use extism_pdk::*;
pub fn greet(name: String) -> FnResult<String> { pub fn greet(name: String) -> FnResult<String> {
Ok(format!("Hello, {}!", name)) Ok(format!("Hello, {}!", name))
} }
#[plugin_fn]
pub fn count_vowels(sentence: String) -> FnResult<String> {
let vowels = "aeiouAEIOU";
let mut vowel_count = 0;
for c in sentence.chars() {
if vowels.contains(c) {
vowel_count += 1;
}
}
Ok(format!("{vowel_count}"))
}