Files
turso/bindings/wasm/lib.rs
Pekka Enberg 3f7c788e5b core: Rename DatabaseStorage methods
Let's call them read_page() and write_page().
2024-08-03 10:35:14 +03:00

53 lines
1.1 KiB
Rust

use limbo_core::Result;
use std::rc::Rc;
use std::sync::Arc;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct Database {
_inner: limbo_core::Database,
}
#[wasm_bindgen]
impl Database {
#[wasm_bindgen(constructor)]
pub fn new(_path: &str) -> Database {
let io = Arc::new(IO {});
let page_io = Rc::new(DatabaseStorage {});
let inner = limbo_core::Database::open(io, page_io).unwrap();
Database { _inner: inner }
}
#[wasm_bindgen]
pub fn exec(&self, _sql: &str) {}
}
pub struct IO {}
impl limbo_core::IO for IO {
fn open_file(&self, _path: &str) -> Result<Rc<dyn limbo_core::File>> {
todo!();
}
fn run_once(&self) -> Result<()> {
todo!();
}
}
pub struct DatabaseStorage {}
impl limbo_core::DatabaseStorage for DatabaseStorage {
fn read_page(&self, _page_idx: usize, _c: Rc<limbo_core::Completion>) -> Result<()> {
todo!();
}
fn write_page(
&self,
_page_idx: usize,
_buffer: Rc<std::cell::RefCell<limbo_core::Buffer>>,
_c: Rc<limbo_core::Completion>,
) -> Result<()> {
todo!()
}
}