use super::super::{super::super::store::*, super::bindings::floria::plugins::floria as bindings, host::*};
use wasmtime::component::*;
#[derive(Clone, Debug)]
pub struct Call {
pub plugin: String,
pub function: String,
pub arguments: Vec<bindings::Expression>,
pub kind: bindings::CallKind,
}
impl Call {
pub fn new(
plugin: String,
function: String,
arguments: Vec<bindings::Expression>,
kind: bindings::CallKind,
) -> Self {
Self { plugin, function, arguments, kind }
}
}
impl<StoreT> bindings::HostCallResource for PluginHost<StoreT>
where
StoreT: Store,
{
fn new(
&mut self,
plugin: String,
function: String,
arguments: Vec<bindings::Expression>,
kind: bindings::CallKind,
) -> wasmtime::Result<Resource<Call>> {
Ok(self.resources.push(Call::new(plugin, function, arguments, kind))?)
}
fn drop(&mut self, resource: Resource<Call>) -> wasmtime::Result<()> {
self.resources.delete(resource)?;
Ok(())
}
fn inner(
&mut self,
resource: Resource<Call>,
) -> wasmtime::Result<(String, String, Vec<bindings::Expression>, bindings::CallKind)> {
let call = self.resources.get(&resource)?;
Ok((call.plugin.clone(), call.function.clone(), call.arguments.clone(), call.kind))
}
}