Create Identifer to help keep track of plugin resources.

This commit is contained in:
we sell insurance 2024-08-31 17:24:43 -05:00
parent e4fd015265
commit 14e59dfb8f
No known key found for this signature in database
5 changed files with 25 additions and 5 deletions

9
Cargo.lock generated
View File

@ -1972,6 +1972,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"extism", "extism",
"log", "log",
"serde",
] ]
[[package]] [[package]]
@ -2404,9 +2405,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.205" version = "1.0.209"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@ -2422,9 +2423,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.205" version = "1.0.209"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -5,4 +5,5 @@ edition.workspace = true
[dependencies] [dependencies]
extism = "1.5.0" extism = "1.5.0"
log.workspace = true log.workspace = true
serde ={ version = "1.0.209", features = ["derive"] }

View File

@ -0,0 +1,15 @@
use extism::{convert::Msgpack, host_fn, FromBytes, ToBytes};
use serde::{Deserialize, Serialize};
/// Used to keep track of things created by plugins.
/// This can include things like events, commands, etc.
#[derive(Hash, PartialEq, Eq, ToBytes, FromBytes, Serialize, Deserialize)]
#[encoding(Msgpack)]
struct Identifier {
namespace: String,
path: String,
}
host_fn!(new(namespace: String, path: String) -> Result<Identifier, _> {
Ok(Identifier { namespace, path })
});

View File

@ -0,0 +1 @@
mod identifer;

View File

@ -1,3 +1,5 @@
mod api;
use std::path::Path; use std::path::Path;
use extism::{Manifest, Plugin, Wasm}; use extism::{Manifest, Plugin, Wasm};