Write plugin to be used in app
This commit is contained in:
parent
c7fde2a87e
commit
dfc8cf908d
12
src/lib.rs
12
src/lib.rs
@ -4,3 +4,15 @@ use extism_pdk::*;
|
||||
pub fn greet(name: String) -> FnResult<String> {
|
||||
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}"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user