Pumpkin/pumpkin-plugin/src/api/identifer.rs
2024-09-01 08:16:43 -05:00

16 lines
537 B
Rust

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)] // TODO: Switch to protocal buffers for smaller size
struct Identifier {
namespace: String,
path: String,
}
host_fn!(new(namespace: String, path: String) -> Result<Identifier, _> {
Ok(Identifier { namespace, path })
});