worker_plus_sys/
d1.rs

1use ::js_sys::Object;
2use wasm_bindgen::prelude::*;
3
4use js_sys::{Array, Promise};
5
6#[wasm_bindgen]
7extern "C" {
8    #[derive(Debug, Clone)]
9    pub type D1Result;
10
11    #[wasm_bindgen(structural, method, getter, js_name=results)]
12    pub fn results(this: &D1Result) -> Option<Array>;
13
14    #[wasm_bindgen(structural, method, getter, js_name=success)]
15    pub fn success(this: &D1Result) -> bool;
16
17    #[wasm_bindgen(structural, method, getter, js_name=error)]
18    pub fn error(this: &D1Result) -> Option<String>;
19
20    #[wasm_bindgen(structural, method, getter, js_name=meta)]
21    pub fn meta(this: &D1Result) -> Object;
22}
23
24#[wasm_bindgen]
25extern "C" {
26    #[derive(Debug, Clone)]
27    pub type D1ExecResult;
28
29    #[wasm_bindgen(structural, method, getter, js_name=count)]
30    pub fn count(this: &D1ExecResult) -> Option<u32>;
31
32    #[wasm_bindgen(structural, method, getter, js_name=time)]
33    pub fn time(this: &D1ExecResult) -> Option<f64>;
34}
35
36#[wasm_bindgen]
37extern "C" {
38    #[wasm_bindgen(extends=::js_sys::Object, js_name=D1Database)]
39    #[derive(Debug, Clone, PartialEq, Eq)]
40    pub type D1Database;
41
42    #[wasm_bindgen(structural, method, js_class=D1Database, js_name=prepare)]
43    pub fn prepare(this: &D1Database, query: &str) -> D1PreparedStatement;
44
45    #[wasm_bindgen(structural, method, js_class=D1Database, js_name=dump)]
46    pub fn dump(this: &D1Database) -> Promise;
47
48    #[wasm_bindgen(structural, method, js_class=D1Database, js_name=batch)]
49    pub fn batch(this: &D1Database, statements: Array) -> Promise;
50
51    #[wasm_bindgen(structural, method, js_class=D1Database, js_name=exec)]
52    pub fn exec(this: &D1Database, query: &str) -> Promise;
53}
54
55#[wasm_bindgen]
56extern "C" {
57    #[wasm_bindgen(extends=::js_sys::Object, js_name=D1PreparedStatement)]
58    #[derive(Debug, Clone, PartialEq, Eq)]
59    pub type D1PreparedStatement;
60
61    #[wasm_bindgen(structural, method, js_class=D1PreparedStatement, js_name=bind, catch)]
62    pub fn bind(this: &D1PreparedStatement, values: Array) -> Result<D1PreparedStatement, JsValue>;
63
64    #[wasm_bindgen(structural, method, js_class=D1PreparedStatement, js_name=first)]
65    pub fn first(this: &D1PreparedStatement, col_name: Option<&str>) -> Promise;
66
67    #[wasm_bindgen(structural, method, js_class=D1PreparedStatement, js_name=run)]
68    pub fn run(this: &D1PreparedStatement) -> Promise;
69
70    #[wasm_bindgen(structural, method, js_class=D1PreparedStatement, js_name=all)]
71    pub fn all(this: &D1PreparedStatement) -> Promise;
72
73    #[wasm_bindgen(structural, method, js_class=D1PreparedStatement, js_name=raw)]
74    pub fn raw(this: &D1PreparedStatement) -> Promise;
75}