mirror of
https://github.com/extism/extism.git
synced 2026-04-23 03:00:11 -04:00
Bumps [ex_doc](https://github.com/elixir-lang/ex_doc) from 0.29.4 to 0.30.1. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/elixir-lang/ex_doc/blob/main/CHANGELOG.md">ex_doc's changelog</a>.</em></p> <blockquote> <h2>v0.30.1 (2023-07-07)</h2> <ul> <li>Bug fixes <ul> <li>Fix styling for headers on cheatsheets and small screens</li> </ul> </li> </ul> <h2>v0.30.0 (2023-07-07)</h2> <ul> <li> <p>Enhancements</p> <ul> <li>Support tabsets (see the README for more information)</li> <li>Improve search results and indexing by storing more data and metadata</li> <li>Warn on invalid references in links</li> <li>Strike-through deprecated items on autocompletion</li> <li>Add source URL link to API reference page</li> <li>Allow multiple extra files with the same name by generating unique names in case of conflicts</li> </ul> </li> <li> <p>Bug fixes</p> <ul> <li>Fix rendering of large code blocks in admonition texts</li> <li>Do not log errors on module mismatch in case-insensitive file systems</li> </ul> </li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="0d2f4dc62d"><code>0d2f4dc</code></a> Release v0.30.1</li> <li><a href="0e9349ef73"><code>0e9349e</code></a> Update assets</li> <li><a href="11dda904d2"><code>11dda90</code></a> Fix bugs in headers</li> <li><a href="2ffaa811b0"><code>2ffaa81</code></a> Release v0.30.0</li> <li><a href="964a22658c"><code>964a226</code></a> Update assets</li> <li><a href="091fb70432"><code>091fb70</code></a> Revert "Make dummy assets change"</li> <li><a href="948825d73f"><code>948825d</code></a> Update assets</li> <li><a href="7e661dc589"><code>7e661dc</code></a> Make dummy assets change</li> <li><a href="7d3d195acb"><code>7d3d195</code></a> Update assets on CI (<a href="https://redirect.github.com/elixir-lang/ex_doc/issues/1731">#1731</a>)</li> <li><a href="c54c5e63d9"><code>c54c5e6</code></a> Remove padding on anchor</li> <li>Additional commits viewable in <a href="https://github.com/elixir-lang/ex_doc/compare/v0.29.4...v0.30.1">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Extism
Extism Host SDK for Elixir and Erlang
Docs
Read the docs on hexdocs.pm.
Installation
You can find this package on hex.pm.
def deps do
[
{:extism, "~> 0.1.0"}
]
end
Getting Started
Example
# Create a context for which plugins can be allocated and cleaned
ctx = Extism.Context.new()
# point to some wasm code, this is the count_vowels example that ships with extism
manifest = %{ wasm: [ %{ path: "/Users/ben/code/extism/wasm/code.wasm" } ]}
{:ok, plugin} = Extism.Context.new_plugin(ctx, manifest, false)
# {:ok,
# %Extism.Plugin{
# resource: 0,
# reference: #Reference<0.520418104.1263009793.80956>
# }}
{:ok, output} = Extism.Plugin.call(plugin, "count_vowels", "this is a test")
# {:ok, "{\"count\": 4}"}
{:ok, result} = JSON.decode(output)
# {:ok, %{"count" => 4}}
# free up the context and any plugins we allocated
Extism.Context.free(ctx)
Modules
The two primary modules you should learn are:
Context
The Context can be thought of as a session. You need a context to interact with the Extism runtime. The context holds your plugins and when you free the context, it frees your plugins. It's important to free up your context and plugins when you are done with them.
ctx = Extism.Context.new()
# frees all the plugins
Extism.Context.reset(ctx)
# frees the context and all its plugins
Extism.Context.free(ctx)
Plugin
The Plugin represents an instance of your WASM program from the given manifest. The key method to know here is Extism.Plugin#call which takes a function name to invoke and some input data, and returns the results from the plugin.
{:ok, plugin} = Extism.Context.new_plugin(ctx, manifest, false)
{:ok, output} = Extism.Plugin.call(plugin, "count_vowels", "this is a test")