Plug-ins: manifests list permissions, the user grants them at install, and the host enforces the grant

A manifest may list `permissions` (doc.read, doc.write, state,
effect.render, export.write) and an `api` level. doc.read, doc.write
and state follow the capability model proposed in
storytold/photocraft#662; the other names are VectorCraft's own. An
unknown, reserved, duplicate or wrong-kind name is refused by name. A
manifest without the key gets the permissions its kind implies and
installs as before.

- Install Plug-in... and File > Open show the name, id, version, file
  SHA-256 and each permission in plain words, with control and
  bidirectional characters escaped and each string cut to 64
  characters. OK installs the module only if it still has the SHA-256
  shown; Cancel installs nothing. The heavy-budget prompt and the
  status line show the escaped name too, and OK keeps the `replace` it
  was given.
- `plugin.install` needs `grant` listing every permission, and
  `plugin.inspect` reports `needsApproval`. `hash` pins the module:
  one with another SHA-256 is refused. The grant is kept with the
  module's hash in the store's `grants.json`, and only that store's
  grants count while it is attached; the same set does not ask again,
  more permissions do, and `plugin.remove` forgets it.
- The Additional Plug-ins Folder and `plugin.reload` install only
  plug-ins the attached store has granted and report the others as
  needing approval. At startup the store skips an ungranted plug-in.
- A filter run without doc.read is given no objects; without state it
  neither reads nor writes `documentData`; without doc.write an output
  that changes the document is refused and the document is unchanged.

Docs: docs/plugins.md, docs/mcp.md, docs/target-app-parity.md.
This commit is contained in:
dotCooCoo
2026-11-07 15:20:07 -08:00
parent ff9deee46d
commit 1f352bc7c1
45 changed files with 1583 additions and 50 deletions
+3 -1
View File
@@ -21,7 +21,8 @@
//! time it is drawn, from an appearance stack; an **exporter** ([`export`]) writes the whole
//! document in a file format of its own. The process-wide [`registry`] holds the installed
//! plug-ins. A plug-in's parameters ([`manifest`]) come with what the host's dialogs need to show
//! them well: labels, units, groups, help and conditions ([`dialog`]).
//! them well: labels, units, groups, help and conditions ([`dialog`]). What a plug-in may do is
//! the set of [`permissions`] its manifest lists, which the user approves when it is installed.
#![forbid(unsafe_code)]
pub mod dialog;
@@ -29,6 +30,7 @@ pub mod effect;
pub mod export;
pub mod manifest;
pub mod objects;
pub mod permissions;
pub mod registry;
mod runtime;
pub mod wat;
+68
View File
@@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
use serde_json::{Map, Value, json};
use crate::dialog::ParamUi;
use crate::permissions::{self, API_LEVEL, Permission};
use crate::{Error, Result};
/// Longest manifest the host reads.
@@ -154,6 +155,12 @@ fn text_max() -> usize {
fn list_max() -> usize {
16
}
fn first_api() -> u32 {
1
}
fn is_first_api(api: &u32) -> bool {
*api == 1
}
/// One declared parameter: what it holds, and how dialogs show it. In the manifest both are keys of
/// the same object: `{"type": "number", "min": 0, "max": 10, "default": 1, "unit": "mm"}`.
@@ -236,6 +243,13 @@ pub struct Manifest {
pub description: String,
#[serde(default)]
pub author: String,
/// The plug-in API level it was built for, 1 to [`API_LEVEL`] (1 when left out).
#[serde(default = "first_api", skip_serializing_if = "is_first_api")]
pub api: u32,
/// The permissions it asks for ([`crate::permissions`]), which the user approves when it is
/// installed. Left out, it gets the ones its kind implies ([`Permission::implied`]).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub permissions: Option<Vec<String>>,
/// Parameters in declaration (dialog) order; a JSON object `{"name": spec, …}` in the manifest.
#[serde(default, deserialize_with = "ordered_params", serialize_with = "params_as_object")]
pub params: Vec<(String, Param)>,
@@ -269,6 +283,8 @@ impl Manifest {
kind: Kind::Filter,
description: String::new(),
author: String::new(),
api: 1,
permissions: None,
params: Vec::new(),
extensions: Vec::new(),
budget: Budget::Light,
@@ -288,6 +304,12 @@ impl Manifest {
if self.version.len() > 32 || self.description.len() > 1024 || self.author.len() > 128 {
return Err(Error::Manifest("`version`, `description` or `author` is too long".into()));
}
if !(1..=API_LEVEL).contains(&self.api) {
return Err(Error::Manifest(format!("`api` is {}; this host implements plug-in API levels 1 to {API_LEVEL}", self.api)));
}
if let Some(names) = &self.permissions {
permissions::validate(self.kind, names)?;
}
self.validate_extensions()?;
match (self.budget, self.kind) {
(Budget::Light, _) | (Budget::Heavy, Kind::Filter) => {}
@@ -363,6 +385,19 @@ impl Manifest {
self.params.iter().map(|(k, p)| (k.clone(), p.spec.default_value())).collect()
}
/// What the plug-in may do: the permissions it lists, else the ones its kind implies.
pub fn permissions(&self) -> Vec<Permission> {
match &self.permissions {
Some(names) => permissions::validate(self.kind, names).unwrap_or_default(),
None => Permission::implied(self.kind).to_vec(),
}
}
/// Does installing it need the user's approval: does it list permissions?
pub fn asks_permissions(&self) -> bool {
self.permissions.as_ref().is_some_and(|p| !p.is_empty())
}
/// Validates user `params` against the schema: missing keys take their defaults, numbers are
/// clamped into range (whole numbers rounded), unknown keys are dropped; a value of the wrong
/// type is an error.
@@ -595,6 +630,39 @@ mod tests {
}
}
/// A manifest lists the permissions it asks for, checked against its kind; without the key it
/// gets the ones its kind implies, as plug-ins did before manifests listed them, and needs no
/// approval. `api` is 1 when left out, and a later level is refused.
#[test]
fn permissions_and_api_level() {
let listed = Manifest::parse(br#"{"id":"a","name":"x","kind":"filter","api":1,"permissions":["doc.write","doc.read"]}"#).unwrap();
assert_eq!(listed.permissions(), [Permission::DocRead, Permission::DocWrite]);
assert!(listed.asks_permissions());
assert_eq!(serde_json::to_value(&listed).unwrap()["permissions"], json!(["doc.write", "doc.read"]));
assert!(serde_json::to_value(&listed).unwrap().get("api").is_none(), "level 1 isn't written back");
let plain = Manifest::parse(br#"{"id":"a","name":"x","kind":"filter"}"#).unwrap();
assert_eq!((plain.api, plain.asks_permissions()), (1, false));
assert_eq!(plain.permissions(), [Permission::DocRead, Permission::DocWrite, Permission::State]);
assert!(serde_json::to_value(&plain).unwrap().get("permissions").is_none());
let effect = Manifest::parse(br#"{"id":"a","name":"x","kind":"effect"}"#).unwrap();
assert_eq!(effect.permissions(), [Permission::DocRead, Permission::EffectRender]);
let exporter = Manifest::parse(br#"{"id":"a","name":"x","kind":"exporter","extensions":["plt"]}"#).unwrap();
assert_eq!(exporter.permissions(), [Permission::DocRead, Permission::ExportWrite]);
assert!(!Manifest::parse(br#"{"id":"a","name":"x","kind":"filter","permissions":[]}"#).unwrap().asks_permissions());
for (bad, says) in [
(r#"{"id":"a","name":"x","kind":"filter","permissions":["doc.read","net.fetch"]}"#, "unknown permission `net.fetch`"),
(r#"{"id":"a","name":"x","kind":"filter","permissions":["ui.panel"]}"#, "reserved"),
(r#"{"id":"a","name":"x","kind":"effect","permissions":["doc.read"]}"#, "effect.render"),
(r#"{"id":"a","name":"x","kind":"filter","permissions":"doc.read"}"#, "manifest"),
(r#"{"id":"a","name":"x","kind":"filter","api":2}"#, "`api` is 2"),
(r#"{"id":"a","name":"x","kind":"filter","api":0}"#, "`api` is 0"),
(r#"{"id":"a","name":"x","kind":"filter","api":-1}"#, "manifest"),
] {
let e = Manifest::parse(bad.as_bytes()).unwrap_err().to_string();
assert!(e.contains(says), "{bad}: {e}");
}
}
#[test]
fn strings_and_number_lists_resolve_like_the_other_types() {
let m = Manifest::parse(
+266
View File
@@ -0,0 +1,266 @@
//! What a plug-in may do: the permissions its manifest lists (`permissions`), which the user
//! approves when it is installed ([`Grant`], kept in [`crate::registry`]), and which the host
//! enforces on every run.
//!
//! `doc.read`, `doc.write`, `state` and the reserved `progress` are the names of the plug-in
//! capability model in storytold/photocraft#662; the other names are VectorCraft's own. A manifest
//! without `permissions` gets the ones its kind implies ([`Permission::implied`]): what every
//! plug-in of that kind could do before manifests listed them.
use serde::{Deserialize, Serialize};
use crate::{Error, Kind, Result};
/// The plug-in API level this host implements. A manifest's `api` (1 when left out) may be at most
/// this.
pub const API_LEVEL: u32 = 1;
/// Most permissions a manifest may list.
pub const MAX_PERMISSIONS: usize = 16;
/// Longest plug-in name a prompt shows, in characters.
pub const MAX_SHOWN_NAME: usize = 64;
/// Longest version or id a prompt shows, in characters.
pub const MAX_SHOWN_FIELD: usize = 64;
/// Names kept for host calls a later plug-in API adds. This host grants none of them, so a
/// manifest that lists one is refused when it is installed.
pub const RESERVED: &[&str] = &["progress", "ui.panel", "ui.tool"];
/// One thing a plug-in may do.
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum Permission {
/// Read the objects the host hands it: a filter's selected paths, the object a live effect is
/// on, the document an exporter writes.
#[serde(rename = "doc.read")]
DocRead,
/// Change, add and delete objects (a filter's output), as one undo step.
#[serde(rename = "doc.write")]
DocWrite,
/// Read and write the data it keeps with the document (a filter's `documentData`).
#[serde(rename = "state")]
State,
/// Change how the objects its live effect is applied to are drawn.
#[serde(rename = "effect.render")]
EffectRender,
/// Write the document as a file in its own format (an exporter).
#[serde(rename = "export.write")]
ExportWrite,
}
/// Every permission this host grants, in the order prompts list them.
pub const ALL: [Permission; 5] = [Permission::DocRead, Permission::DocWrite, Permission::State, Permission::EffectRender, Permission::ExportWrite];
impl Permission {
/// Its name in a manifest and in `plugin.install`'s `grant`.
pub fn name(self) -> &'static str {
match self {
Permission::DocRead => "doc.read",
Permission::DocWrite => "doc.write",
Permission::State => "state",
Permission::EffectRender => "effect.render",
Permission::ExportWrite => "export.write",
}
}
/// The permission named `name`.
pub fn parse(name: &str) -> Option<Permission> {
ALL.into_iter().find(|p| p.name() == name)
}
/// What it lets a plug-in do, in plain words (English; the app shows its own translation).
pub fn describe(self) -> &'static str {
match self {
Permission::DocRead => "Read the objects it is given",
Permission::DocWrite => "Change, add and delete objects in the document",
Permission::State => "Keep data of its own with the document",
Permission::EffectRender => "Change how the objects its effect is applied to are drawn",
Permission::ExportWrite => "Write the document as a file in its own format",
}
}
/// The permissions a plug-in of `kind` may list, which are also the ones a manifest without
/// `permissions` gets.
pub fn implied(kind: Kind) -> &'static [Permission] {
match kind {
Kind::Filter => &[Permission::DocRead, Permission::DocWrite, Permission::State],
Kind::Effect => &[Permission::DocRead, Permission::EffectRender],
Kind::Exporter => &[Permission::DocRead, Permission::ExportWrite],
}
}
/// The permissions a plug-in of `kind` can't work without, which its list must hold: a live
/// effect and an exporter are always handed objects, and only draw or write. A filter may
/// leave any of its permissions out.
fn required(kind: Kind) -> &'static [Permission] {
match kind {
Kind::Filter => &[],
Kind::Effect | Kind::Exporter => Permission::implied(kind),
}
}
}
/// Checks the `permissions` a manifest of `kind` lists → them, in the order [`ALL`] has. A name
/// that is not a permission, a reserved one, one that doesn't apply to the kind, one listed twice
/// and a list without what the kind needs are errors that name it.
pub(crate) fn validate(kind: Kind, names: &[String]) -> Result<Vec<Permission>> {
if names.len() > MAX_PERMISSIONS {
return Err(Error::Manifest(format!("at most {MAX_PERMISSIONS} `permissions`")));
}
let mut out: Vec<Permission> = Vec::with_capacity(names.len());
for name in names {
let shown = display_text(name, MAX_SHOWN_FIELD);
let Some(p) = Permission::parse(name) else {
if RESERVED.contains(&name.as_str()) {
return Err(Error::Manifest(format!("permission `{shown}` is reserved for a later plug-in API; this host doesn't grant it")));
}
return Err(Error::Manifest(format!("unknown permission `{shown}`")));
};
if !Permission::implied(kind).contains(&p) {
return Err(Error::Manifest(format!("permission `{shown}` doesn't apply to a plug-in of kind `{}`", kind.name())));
}
if out.contains(&p) {
return Err(Error::Manifest(format!("permission `{shown}` is listed twice")));
}
out.push(p);
}
if let Some(missing) = Permission::required(kind).iter().find(|p| !out.contains(p)) {
return Err(Error::Manifest(format!("a plug-in of kind `{}` needs the permission `{}`", kind.name(), missing.name())));
}
out.sort();
Ok(out)
}
/// The names of `permissions`, as a manifest and `grant` list them.
pub fn names(permissions: &[Permission]) -> Vec<&'static str> {
permissions.iter().map(|p| p.name()).collect()
}
/// Is `c` a character that changes the direction text is laid out in, or a line or paragraph
/// separator, which a prompt must not let a manifest string use to disguise itself?
fn is_bidi_or_separator(c: char) -> bool {
matches!(c, '\u{061C}' | '\u{200E}' | '\u{200F}' | '\u{202A}'..='\u{202E}' | '\u{2066}'..='\u{2069}' | '\u{2028}' | '\u{2029}')
}
/// `s` as a prompt shows a string from a manifest: control, bidirectional formatting and line
/// separator characters written as `\u{202E}` escapes, and at most `max` characters, the last of
/// them `…` when it was cut.
pub fn display_text(s: &str, max: usize) -> String {
use std::fmt::Write as _;
let mut out = String::new();
// Characters written so far, and the byte length of the longest prefix of whole pieces
// shorter than `max` characters, where the ellipsis goes when the text is cut.
let mut count = 0;
let mut cut = 0;
for c in s.chars() {
let start = out.len();
let n = if c.is_control() || is_bidi_or_separator(c) {
let _ = write!(out, "\\u{{{:04X}}}", c as u32);
out.len() - start
} else {
out.push(c);
1
};
if count + n > max {
out.truncate(cut);
out.push('…');
return out;
}
count += n;
if count < max {
cut = out.len();
}
}
out
}
/// The SHA-256 of `bytes`, in lower-case hexadecimal.
pub fn sha256_hex(bytes: &[u8]) -> String {
use sha2::{Digest, Sha256};
Sha256::digest(bytes).iter().map(|b| format!("{b:02x}")).collect()
}
/// What the user approved for a plug-in: its id, the SHA-256 of the module they approved
/// ([`sha256_hex`]) and the permissions it was granted.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Grant {
pub id: String,
pub hash: String,
pub permissions: Vec<Permission>,
}
impl Grant {
/// Does it grant every one of `wanted`?
pub fn covers(&self, wanted: &[Permission]) -> bool {
wanted.iter().all(|w| self.permissions.contains(w))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn names_round_trip_and_serialize_as_names() {
for p in ALL {
assert_eq!(Permission::parse(p.name()), Some(p));
assert_eq!(serde_json::to_value(p).unwrap(), serde_json::json!(p.name()));
}
assert_eq!(Permission::parse("document.read"), None);
assert!(RESERVED.iter().all(|r| Permission::parse(r).is_none()), "reserved names are not granted");
}
#[test]
fn lists_are_checked_against_the_kind() {
let list = |names: &[&str]| names.iter().map(|s| s.to_string()).collect::<Vec<_>>();
assert_eq!(validate(Kind::Filter, &list(&["doc.write", "doc.read"])).unwrap(), [Permission::DocRead, Permission::DocWrite]);
assert_eq!(validate(Kind::Filter, &[]).unwrap(), []);
assert!(validate(Kind::Effect, &list(&["doc.read", "effect.render"])).is_ok());
assert!(validate(Kind::Exporter, &list(&["export.write", "doc.read"])).is_ok());
for (kind, names, says) in [
(Kind::Filter, &["doc.read", "clipboard"][..], "unknown permission `clipboard`"),
(Kind::Filter, &["progress"], "`progress` is reserved"),
(Kind::Filter, &["export.write"], "doesn't apply to a plug-in of kind `filter`"),
(Kind::Exporter, &["doc.read", "export.write", "doc.read"], "`doc.read` is listed twice"),
(Kind::Effect, &["doc.read"], "needs the permission `effect.render`"),
(Kind::Exporter, &["export.write"], "needs the permission `doc.read`"),
] {
let e = validate(kind, &list(names)).unwrap_err().to_string();
assert!(e.contains(says), "{names:?}: {e}");
}
let many = list(&["doc.read"; MAX_PERMISSIONS + 1]);
assert!(validate(Kind::Filter, &many).unwrap_err().to_string().contains("at most"));
}
/// Control, bidirectional override and separator characters show as escapes, so a name can't
/// reverse or hide the text after it; long text is cut with an ellipsis.
#[test]
fn prompt_text_escapes_hidden_characters_and_is_capped() {
assert_eq!(display_text("Tidy\u{202E}fdp.exe", 64), "Tidy\\u{202E}fdp.exe");
assert_eq!(display_text("a\u{0007}b\nc\u{2066}d\u{200F}", 64), "a\\u{0007}b\\u{000A}c\\u{2066}d\\u{200F}");
assert_eq!(display_text("plain", 64), "plain");
assert_eq!(display_text("abcdef", 6), "abcdef");
assert_eq!(display_text("abcdefg", 6), "abcde…");
assert_eq!(display_text(&"x".repeat(500), MAX_SHOWN_NAME).chars().count(), MAX_SHOWN_NAME);
assert_eq!(display_text("ab\u{202E}", 6), "ab…", "an escape that doesn't fit is cut whole");
assert_eq!(display_text("ab\u{0007}", 10), "ab\\u{0007}", "an escape that ends exactly at the cap is kept");
let long = display_text(&"\u{202E}y".repeat(500_000), MAX_SHOWN_NAME);
assert_eq!(long.chars().count(), MAX_SHOWN_NAME);
assert!(long.starts_with("\\u{202E}y\\u{202E}y") && long.ends_with('…'), "{long}");
}
#[test]
fn hashes_are_sha256_in_hex() {
assert_eq!(sha256_hex(b"abc"), "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
}
#[test]
fn a_grant_covers_its_permissions_and_no_more() {
let g = Grant { id: "a".into(), hash: String::new(), permissions: vec![Permission::DocRead, Permission::DocWrite] };
assert!(g.covers(&[Permission::DocRead]));
assert!(g.covers(&[]));
assert!(!g.covers(&[Permission::State]));
assert!(!g.covers(&[Permission::DocRead, Permission::State]));
}
}
+48 -5
View File
@@ -9,10 +9,41 @@ use std::sync::{Arc, Mutex, RwLock};
#[cfg(not(target_arch = "wasm32"))]
use crate::Error;
use crate::permissions::Grant;
use crate::{Limits, Plugin, Result};
static PLUGINS: RwLock<BTreeMap<String, Arc<Plugin>>> = RwLock::new(BTreeMap::new());
static REVISION: AtomicU64 = AtomicU64::new(0);
/// What the user approved, by plug-in id.
static GRANTS: RwLock<BTreeMap<String, Grant>> = RwLock::new(BTreeMap::new());
/// Records what the user approved for a plug-in, replacing an earlier grant for its id.
pub fn grant(g: Grant) {
GRANTS.write().unwrap_or_else(|e| e.into_inner()).insert(g.id.clone(), g);
}
/// What the user approved for plug-in `id`.
pub fn granted(id: &str) -> Option<Grant> {
GRANTS.read().unwrap_or_else(|e| e.into_inner()).get(id).cloned()
}
/// Every grant, sorted by id.
pub fn grants() -> Vec<Grant> {
GRANTS.read().unwrap_or_else(|e| e.into_inner()).values().cloned().collect()
}
/// Forgets what the user approved for `id`; false if nothing was.
pub fn revoke(id: &str) -> bool {
GRANTS.write().unwrap_or_else(|e| e.into_inner()).remove(id).is_some()
}
/// May `plugin` be installed without asking the user: does it list no permissions, or did the user
/// already grant its id every permission it lists? A module with other bytes but no new permission
/// needs no new approval.
pub fn approved(plugin: &Plugin) -> bool {
let m = plugin.manifest();
!m.asks_permissions() || granted(&m.id).is_some_and(|g| g.covers(&m.permissions()))
}
/// Installs `plugin`, replacing one with the same id.
pub fn install(mut plugin: Plugin) -> Arc<Plugin> {
@@ -93,16 +124,21 @@ pub struct FolderReport {
/// Installs every `*.wasm` directly in `dir` (not recursive), in file-name order. A bad module is
/// reported and skipped, the others still load; so is a heavy one ([`crate::Budget::Heavy`]),
/// which installs only once the user agrees.
/// which installs only once the user agrees, and one that lists permissions the user has not
/// granted its id ([`approved`]).
#[cfg(not(target_arch = "wasm32"))]
pub fn load_folder(dir: &std::path::Path) -> Result<FolderReport> {
load_folder_where(dir, |_| Ok(()))
load_folder_where(dir, |_| Ok(()), approved)
}
/// [`load_folder`], loading only the files `allow` accepts; the others are reported as failed
/// with its reason.
/// [`load_folder`], loading only the files `allow` accepts, and of the plug-ins that list
/// permissions only those `approve` accepts; the others are reported as failed with the reason.
#[cfg(not(target_arch = "wasm32"))]
pub fn load_folder_where(dir: &std::path::Path, allow: impl Fn(&std::path::Path) -> std::result::Result<(), String>) -> Result<FolderReport> {
pub fn load_folder_where(
dir: &std::path::Path,
allow: impl Fn(&std::path::Path) -> std::result::Result<(), String>,
approve: impl Fn(&Plugin) -> bool,
) -> Result<FolderReport> {
let rd = std::fs::read_dir(dir).map_err(|e| Error::Io(format!("{}: {e}", dir.display())))?;
let mut files: Vec<std::path::PathBuf> =
rd.filter_map(|e| e.ok().map(|e| e.path())).filter(|p| p.extension().is_some_and(|x| x.eq_ignore_ascii_case("wasm"))).collect();
@@ -119,6 +155,13 @@ pub fn load_folder_where(dir: &std::path::Path, allow: impl Fn(&std::path::Path)
Ok(p) if p.manifest().budget == crate::Budget::Heavy => {
report.failed.push((f.display().to_string(), "asks for a heavy budget, which the user allows when installing it on its own".into()));
}
Ok(p) if p.manifest().asks_permissions() && !approve(&p) => {
let asked = crate::permissions::names(&p.manifest().permissions()).join(", ");
report.failed.push((
f.display().to_string(),
format!("needs approval: it asks for {asked}, which the user grants when installing it on its own"),
));
}
Ok(p) => report.loaded.push(install(p).id().to_string()),
Err(e) => report.failed.push((f.display().to_string(), e.to_string())),
}
+7 -1
View File
@@ -85,6 +85,7 @@ pub struct Plugin {
module: Module,
limits: Limits,
size: usize,
hash: String,
source: Option<String>,
serial: u64,
}
@@ -174,7 +175,8 @@ impl Plugin {
imp.name()
)));
}
let mut p = Plugin { manifest: Manifest::placeholder(), engine, module, limits, size: bytes.len(), source: None, serial: 0 };
let hash = crate::permissions::sha256_hex(bytes);
let mut p = Plugin { manifest: Manifest::placeholder(), engine, module, limits, size: bytes.len(), hash, source: None, serial: 0 };
let deadline = Deadline::new(&p.limits);
let mut live = p.instantiate()?;
let version: TypedFunc<(), i32> = live.func("vc_abi_version")?;
@@ -214,6 +216,10 @@ impl Plugin {
pub fn size(&self) -> usize {
self.size
}
/// The module's SHA-256, in lower-case hexadecimal.
pub fn hash(&self) -> &str {
&self.hash
}
/// Where the module was loaded from, if it came from a file.
pub fn source(&self) -> Option<&str> {
self.source.as_deref()