use holo_hash::{AgentPubKey, WasmHash};
use holochain_types::prelude::{CellId, DnaDef, DnaWasmHashed, EntryDef};
use crate::handles::{TxRead, TxWrite};
use crate::kind::Wasm;
use super::{reads, writes};
impl TxRead<Wasm> {
pub async fn wasm_exists(&mut self, hash: &WasmHash) -> sqlx::Result<bool> {
reads::wasm_exists(self.conn_mut(), hash).await
}
pub async fn get_wasm(&mut self, hash: &WasmHash) -> sqlx::Result<Option<DnaWasmHashed>> {
reads::get_wasm(self.conn_mut(), hash).await
}
pub async fn dna_def_exists(&mut self, cell_id: &CellId) -> sqlx::Result<bool> {
reads::dna_def_exists(self.conn_mut(), cell_id).await
}
pub async fn get_dna_def(&mut self, cell_id: &CellId) -> sqlx::Result<Option<DnaDef>> {
reads::get_dna_def(self.tx_mut(), cell_id).await
}
pub async fn entry_def_exists(&mut self, key: &[u8]) -> sqlx::Result<bool> {
reads::entry_def_exists(self.conn_mut(), key).await
}
pub async fn get_entry_def(&mut self, key: &[u8]) -> sqlx::Result<Option<EntryDef>> {
reads::get_entry_def(self.conn_mut(), key).await
}
pub async fn get_all_entry_defs(&mut self) -> sqlx::Result<Vec<(Vec<u8>, EntryDef)>> {
reads::get_all_entry_defs(self.conn_mut()).await
}
pub async fn get_all_dna_defs(&mut self) -> sqlx::Result<Vec<(CellId, DnaDef)>> {
reads::get_all_dna_defs(self.tx_mut()).await
}
}
impl TxWrite<Wasm> {
pub async fn put_wasm(&mut self, wasm: DnaWasmHashed) -> sqlx::Result<()> {
writes::put_wasm(self.conn_mut(), wasm).await
}
pub async fn put_dna_def(&mut self, agent: &AgentPubKey, dna_def: &DnaDef) -> sqlx::Result<()> {
writes::put_dna_def(self.tx_mut(), agent, dna_def).await
}
pub async fn put_entry_def(&mut self, key: Vec<u8>, entry_def: &EntryDef) -> sqlx::Result<()> {
writes::put_entry_def(self.conn_mut(), key, entry_def).await
}
}