wasm-sql 0.1.6

Wasmtime host implementation for a SQL component WIT interface. Enables Wasm components to interact with SQL databases via the WebAssembly Component Model.
Documentation
use crate::{
    core::bindings::{SqlHostState, generated::wasm_sql::core::query_types::QueryResults},
    sqldb::SqlDatabase,
};

#[allow(unused)]
pub struct QueryResultsImpl {
    pub(crate) results: Vec<<SqlDatabase as sqlx::Database>::Row>,
}

impl crate::core::bindings::generated::wasm_sql::core::query_types::HostQueryResults
    for SqlHostState
{
    fn row_count(
        &mut self,
        self_: wasmtime::component::Resource<QueryResults>,
    ) -> Result<u64, wasmtime::Error> {
        let a = self.table.get(&self_)?;

        Ok(a.results.len() as u64)
    }

    fn drop(&mut self, rep: wasmtime::component::Resource<QueryResults>) -> wasmtime::Result<()> {
        self.table.delete(rep)?;

        Ok(())
    }
}