-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Plugin.Typed to define typed plugins (#14)
- Loading branch information
Showing
5 changed files
with
166 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
open Extism | ||
|
||
let url = | ||
"https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm" | ||
|
||
module Typed_example = struct | ||
include Plugin.Typed.Init () | ||
|
||
let count_vowels = exn @@ fn "count_vowels" Type.string Type.json | ||
end | ||
|
||
let () = | ||
let wasm = Manifest.Wasm.url url in | ||
let manifest = Manifest.create [ wasm ] in | ||
let plugin = Plugin.of_manifest_exn manifest in | ||
let plugin = Typed_example.of_plugin_exn plugin in | ||
let res = Typed_example.count_vowels plugin "this is a test" in | ||
print_endline (Yojson.Safe.to_string res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters