-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/rust-build-cache
- Loading branch information
Showing
12 changed files
with
462 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
hermes/bin/src/runtime_extensions/hermes/sqlite/connection/host.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//! `SQLite` connection object host implementation for WASM runtime. | ||
|
||
use crate::{ | ||
runtime_context::HermesRuntimeContext, | ||
runtime_extensions::bindings::hermes::sqlite::api::{ | ||
Errno, HostSqlite, Sqlite, Statement, StatusOptions, | ||
}, | ||
}; | ||
|
||
impl HostSqlite for HermesRuntimeContext { | ||
/// Closes a database connection, destructor for `sqlite3`. | ||
/// | ||
/// Ideally, applications should finalize all prepared statements associated with the | ||
/// `sqlite3` object prior to attempting to close the object. If the database | ||
/// connection is associated with unfinalized prepared statements, | ||
/// then the function will leave the database connection open and return the `busy` | ||
/// error code. | ||
/// | ||
/// If an `sqlite3` object is destroyed while a transaction is open, the transaction | ||
/// is automatically rolled back. | ||
fn close( | ||
&mut self, _self_: wasmtime::component::Resource<Sqlite>, | ||
) -> wasmtime::Result<Result<(), Errno>> { | ||
todo!() | ||
} | ||
|
||
/// Retrieves runtime status information about a single database connection. | ||
/// | ||
/// ## Parameters | ||
/// | ||
/// - `opt`: An integer constant, taken from the set of `status-options`, that | ||
/// determines the parameter to interrogate. | ||
/// - `reset-flag`: If is true, then the highest instantaneous value is reset back | ||
/// down to the current value. | ||
/// | ||
/// ## Returns | ||
/// | ||
/// A tuple of the current value of the requested parameter, and the highest | ||
/// instantaneous value on success, and an error code on failure. | ||
fn status( | ||
&mut self, _self_: wasmtime::component::Resource<Sqlite>, _opt: StatusOptions, | ||
_reset_flag: bool, | ||
) -> wasmtime::Result<Result<(i32, i32), Errno>> { | ||
todo!() | ||
} | ||
|
||
/// Compiles SQL text into byte-code that will do the work of querying or updating the | ||
/// database. | ||
/// | ||
/// ## Parameters | ||
/// | ||
/// - `db`: Database handle. | ||
/// - `sql`: SQL statement, UTF-8 encoded. | ||
/// | ||
/// ## Returns | ||
/// | ||
/// A compiled prepared statement that can be executed using `sqlite3_step()`. | ||
/// If there is an error or the input text contains no SQL (if the input is an empty | ||
/// string or a comment) then an error code is returned. | ||
fn prepare( | ||
&mut self, _db: wasmtime::component::Resource<Sqlite>, _sql: String, | ||
) -> wasmtime::Result<Result<wasmtime::component::Resource<Statement>, Errno>> { | ||
todo!() | ||
} | ||
|
||
/// Executes an SQL query directly without preparing it into a statement and returns | ||
/// the result. | ||
/// | ||
/// ## Parameters | ||
/// | ||
/// - `sql`: SQL statement, UTF-8 encoded. | ||
fn execute( | ||
&mut self, _self_: wasmtime::component::Resource<Sqlite>, _sql: String, | ||
) -> wasmtime::Result<Result<(), Errno>> { | ||
todo!() | ||
} | ||
|
||
fn drop(&mut self, _rep: wasmtime::component::Resource<Sqlite>) -> wasmtime::Result<()> { | ||
todo!() | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
hermes/bin/src/runtime_extensions/hermes/sqlite/connection/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//! `SQLite` connection object runtime extension implementation. | ||
|
||
mod host; | ||
|
||
/// Advise Runtime Extensions of a new context | ||
pub(crate) fn new_context(_ctx: &crate::runtime_context::HermesRuntimeContext) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! `SQLite` host implementation for WASM runtime. | ||
|
||
use crate::{ | ||
runtime_context::HermesRuntimeContext, | ||
runtime_extensions::bindings::hermes::sqlite::api::{Errno, Host, Sqlite}, | ||
}; | ||
|
||
impl Host for HermesRuntimeContext { | ||
/// Opens a connection to a new or existing `SQLite` database. | ||
/// | ||
/// ## Parameters | ||
/// | ||
/// - `readonly`: If set to true, the database is opened in read-only mode. An error | ||
/// is returned if the database doesn't already exist. | ||
/// - `memory`: If set to true, the database will be opened as an in-memory database. | ||
/// | ||
/// ## Returns | ||
/// | ||
/// If the database is opened (and/or created) successfully, then the `sqlite3` object | ||
/// is returned. Otherwise an error code is returned. | ||
fn open( | ||
&mut self, _readonly: bool, _memory: bool, | ||
) -> wasmtime::Result<Result<wasmtime::component::Resource<Sqlite>, Errno>> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//! `SQLite` runtime extension implementation. | ||
|
||
mod connection; | ||
mod host; | ||
mod statement; | ||
|
||
/// Advise Runtime Extensions of a new context | ||
pub(crate) fn new_context(ctx: &crate::runtime_context::HermesRuntimeContext) { | ||
connection::new_context(ctx); | ||
statement::new_context(ctx); | ||
} |
69 changes: 69 additions & 0 deletions
69
hermes/bin/src/runtime_extensions/hermes/sqlite/statement/host.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//! `SQLite` statement host implementation for WASM runtime. | ||
|
||
use crate::{ | ||
runtime_context::HermesRuntimeContext, | ||
runtime_extensions::bindings::hermes::sqlite::api::{Errno, HostStatement, Statement, Value}, | ||
}; | ||
|
||
impl HostStatement for HermesRuntimeContext { | ||
/// Stores application data into parameters of the original SQL. | ||
/// | ||
/// ## Parameters | ||
/// | ||
/// - `index`: The index of the SQL parameter to be set. | ||
/// - `value`: The value to bind to the parameter. | ||
fn bind( | ||
&mut self, _self_: wasmtime::component::Resource<Statement>, _index: u32, _value: Value, | ||
) -> wasmtime::Result<Result<(), Errno>> { | ||
todo!() | ||
} | ||
|
||
/// Advances a statement to the next result row or to completion. | ||
/// | ||
/// After a prepared statement has been prepared, this function must be called one or | ||
/// more times to evaluate the statement. | ||
fn step( | ||
&mut self, _self_: wasmtime::component::Resource<Statement>, | ||
) -> wasmtime::Result<Result<(), Errno>> { | ||
todo!() | ||
} | ||
|
||
/// Returns information about a single column of the current result row of a query. | ||
/// | ||
/// If the SQL statement does not currently point to a valid row, or if the column | ||
/// index is out of range, the result is undefined. | ||
/// | ||
/// ## Parameters | ||
/// | ||
/// - `index`: The index of the column for which information should be returned. The | ||
/// leftmost column of the result set has the index 0. | ||
/// | ||
/// ## Returns | ||
/// | ||
/// The value of a result column in a specific data format. | ||
fn column( | ||
&mut self, _self_: wasmtime::component::Resource<Statement>, _index: u32, | ||
) -> wasmtime::Result<Result<Value, Errno>> { | ||
todo!() | ||
} | ||
|
||
/// Destroys a prepared statement object. If the most recent evaluation of the | ||
/// statement encountered no errors or if the statement is never been evaluated, | ||
/// then the function results without errors. If the most recent evaluation of | ||
/// statement failed, then the function results the appropriate error code. | ||
/// | ||
/// The application must finalize every prepared statement in order to avoid resource | ||
/// leaks. It is a grievous error for the application to try to use a prepared | ||
/// statement after it has been finalized. Any use of a prepared statement after | ||
/// it has been finalized can result in undefined and undesirable behavior such as | ||
/// segfaults and heap corruption. | ||
fn finalize( | ||
&mut self, _self_: wasmtime::component::Resource<Statement>, | ||
) -> wasmtime::Result<Result<(), Errno>> { | ||
todo!() | ||
} | ||
|
||
fn drop(&mut self, _rep: wasmtime::component::Resource<Statement>) -> wasmtime::Result<()> { | ||
todo!() | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
hermes/bin/src/runtime_extensions/hermes/sqlite/statement/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//! `SQLite` statement runtime extension implementation. | ||
|
||
mod host; | ||
|
||
/// Advise Runtime Extensions of a new context | ||
pub(crate) fn new_context(_ctx: &crate::runtime_context::HermesRuntimeContext) {} |
Oops, something went wrong.