Added UUID based, stable workspace ID for caching on item startup. Completed first sketch of terminal persistence. Still need to debug it though....

This commit is contained in:
Mikayla Maki 2022-11-20 22:41:10 -08:00
parent e659823e6c
commit a47f2ca445
20 changed files with 501 additions and 364 deletions

View file

@ -36,6 +36,13 @@ impl Bind for &[u8] {
}
}
impl<const C: usize> Bind for &[u8; C] {
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
statement.bind_blob(start_index, self.as_slice())?;
Ok(start_index + 1)
}
}
impl Bind for Vec<u8> {
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
statement.bind_blob(start_index, self)?;

View file

@ -52,57 +52,3 @@ impl Connection {
Ok(move |bindings| statement.with_bindings(bindings)?.maybe_row::<C>())
}
}
#[macro_export]
macro_rules! exec_method {
($id:ident(): $sql:literal) => {
pub fn $id(&self) -> $crate::anyhow::Result<()> {
iife!({
self.exec($sql)?()
})
}
};
($id:ident($($arg:ident: $arg_type:ty),+): $sql:literal) => {
pub fn $id(&self, $($arg: $arg_type),+) -> $crate::anyhow::Result<()> {
iife!({
self.exec_bound::<($($arg_type),+)>($sql)?(($($arg),+))
})
}
};
}
#[macro_export]
macro_rules! select_method {
($id:ident() -> $return_type:ty: $sql:literal) => {
pub fn $id(&self) -> $crate::anyhow::Result<Vec<$return_type>> {
iife!({
self.select::<$return_type>($sql)?(())
})
}
};
($id:ident($($arg:ident: $arg_type:ty),+) -> $return_type:ty: $sql:literal) => {
pub fn $id(&self, $($arg: $arg_type),+) -> $crate::anyhow::Result<Vec<$return_type>> {
iife!({
self.exec_bound::<($($arg_type),+), $return_type>($sql)?(($($arg),+))
})
}
};
}
#[macro_export]
macro_rules! select_row_method {
($id:ident() -> $return_type:ty: $sql:literal) => {
pub fn $id(&self) -> $crate::anyhow::Result<Option<$return_type>> {
iife!({
self.select_row::<$return_type>($sql)?(())
})
}
};
($id:ident($($arg:ident: $arg_type:ty),+) -> $return_type:ty: $sql:literal) => {
pub fn $id(&self, $($arg: $arg_type),+) -> $crate::anyhow::Result<Option<$return_type>> {
iife!({
self.select_row_bound::<($($arg_type),+), $return_type>($sql)?(($($arg),+))
})
}
};
}