foundation_db 0.0.1

Unified storage backend with Turso sync API, D1, R2, and in-memory fallback
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/// workers-rs interop: `From<worker::D1Database>` for `crate::D1Database`.
///
/// Both types wrap the same underlying JS `D1Database` object. Converting
/// through `JsValue` gives us a zero-cost cast to the foundation_db type
/// so it can be used with `D1WasmStorage` and stored in `ContextBag`.
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use worker::D1Database as WorkerD1Database;

use crate::D1Database;

impl From<WorkerD1Database> for D1Database {
    fn from(db: WorkerD1Database) -> Self {
        let js_val: JsValue = db.into();
        js_val.unchecked_into()
    }
}