1extern crate adapter;
2extern crate adapter_extism;
3extern crate extism;
4
5use adapter::Adapter;
6use adapter_extism::ExtismAdapter;
7
8fn main() {
9 let uri = "https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm";
10
11 let mut adapter = ExtismAdapter::from_url(uri).unwrap();
12
13 let identifier = "count_vowels";
14 let input = "Hello, world!";
15
16 let output: &str = adapter.call(identifier, input).unwrap();
17
18 assert_eq!(output, r#"{"count":3,"total":3,"vowels":"aeiouAEIOU"}"#);
19
20 let generic_output = generic_function(&mut adapter, identifier, input).unwrap();
21
22 assert_eq!(
23 generic_output,
24 r#"{"count":3,"total":6,"vowels":"aeiouAEIOU"}"#
25 );
26}
27
28fn generic_function<'a, T>(
29 adapter: &'a mut T,
30 identifier: T::Identifier,
31 input: &'a str,
32) -> Result<&'a str, T::Error>
33where
34 T: Adapter<'a, &'a str, &'a str> + 'a,
35{
36 adapter.call(identifier, input)
37}