Add most of the dynamic node host implementations
All checks were successful
test / test (push) Successful in 14m4s

This commit is contained in:
2025-01-23 07:48:59 +10:30
parent 9f6fa04dcf
commit 70248de192
11 changed files with 427 additions and 216 deletions

View File

@@ -3,31 +3,31 @@ use std::collections::BTreeMap;
use super::dynamic_state::{vato007::ingey::types::HostCsvRow, DynamicState};
pub struct CsvRow {
values: BTreeMap<String, String>,
pub values: BTreeMap<String, String>,
}
impl HostCsvRow for DynamicState {
fn columns(&mut self,self_:wasmtime::component::Resource<CsvRow>,) -> wasmtime::component::__internal::Vec<wasmtime::component::__internal::String> {
fn columns(&mut self, self_: wasmtime::component::Resource<CsvRow>) -> Vec<String> {
let resource = self.resources.get(&self_).expect("Failed to find the required resource");
resource.values.keys().cloned().collect()
}
fn values(&mut self,self_:wasmtime::component::Resource<CsvRow>,) -> wasmtime::component::__internal::Vec<wasmtime::component::__internal::String> {
fn values(&mut self, self_: wasmtime::component::Resource<CsvRow>) -> Vec<String> {
let resource = self.resources.get(&self_).expect("Failed to find the required resource");
resource.values.values().cloned().collect()
}
fn entries(&mut self,self_:wasmtime::component::Resource<CsvRow>,) -> wasmtime::component::__internal::Vec<(wasmtime::component::__internal::String,wasmtime::component::__internal::String,)> {
fn entries(&mut self, self_: wasmtime::component::Resource<CsvRow>) -> Vec<(String, String,)> {
let resource = self.resources.get(&self_).expect("Failed to find the required resource");
resource.values.keys().map(|key| (key.clone(), resource.values.get(key).unwrap().clone())).collect()
}
fn value(&mut self,self_:wasmtime::component::Resource<CsvRow>,name:wasmtime::component::__internal::String,) -> Option<wasmtime::component::__internal::String> {
fn value(&mut self, self_: wasmtime::component::Resource<CsvRow>, name: String) -> Option<String> {
let resource = self.resources.get(&self_).expect("Failed to find the required resource");
resource.values.get(&name).cloned()
}
fn drop(&mut self,rep:wasmtime::component::Resource<CsvRow>) -> wasmtime::Result<()> {
fn drop(&mut self, rep: wasmtime::component::Resource<CsvRow>) -> wasmtime::Result<()> {
self.resources.delete(rep)?;
Ok(())
}