Files
ingey/src/graph/dynamic/csv_row.rs
vato007 9f6fa04dcf
All checks were successful
test / test (push) Successful in 13m41s
Add structure and interface for csv dynamic node
2025-01-18 14:25:26 +10:30

34 lines
1.7 KiB
Rust

use std::collections::BTreeMap;
use super::dynamic_state::{vato007::ingey::types::HostCsvRow, DynamicState};
pub struct CsvRow {
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> {
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> {
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,)> {
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> {
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<()> {
self.resources.delete(rep)?;
Ok(())
}
}