Skip to content

Commit

Permalink
Merge branch 'main' into fix/rust-build-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenj committed May 8, 2024
2 parents 24d9f6c + 145bfee commit 2a01d0e
Show file tree
Hide file tree
Showing 12 changed files with 462 additions and 9 deletions.
30 changes: 22 additions & 8 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ blockdiag
blockfetch
bmac
BROTLI
CHAINCODE
cantopen
cardano
cdylib
chaincode
cbor
CBOR
cbork
cdylib
CEST
CHAINCODE
chaincode
chainsync
chrono
ciphertext
Expand All @@ -31,8 +32,10 @@ crontabs
crontagged
cryptoxide
dashmap
Datelike
dashmap
Datelike
Datelike
DBSTATUS
dbsync
dcbor
delegators
Expand All @@ -41,7 +44,6 @@ dotenv
dotenvy
dotglob
drep
Datelike
dreps
encryptor
Errno
Expand All @@ -55,6 +57,7 @@ Filesize
filestat
filestorage
filesystems
fkey
fmtchk
fmtfix
fontawesome
Expand All @@ -63,17 +66,19 @@ fstat
fstatat
futimens
genhtml
getres
GETFL
getres
gmtime
happ
hardano
hasher
highwater
hmod
ideascale
idents
IFMT
Intellij
ioerr
iohk
jetbrains
jorm
Expand All @@ -85,6 +90,8 @@ libtest
linkat
lintfix
localizable
lookaside
maindbname
mdlint
miniprotocol
miniprotocols
Expand All @@ -98,6 +105,8 @@ multiera
nanos
netkey
nextest
nolfs
notadb
nsec
oneshot
openapi
Expand All @@ -117,10 +126,11 @@ preopened
preopens
preprod
psql
pubkey
pubk
pubkey
pubspec
pwrite
qpsg
rapidoc
readlinkat
redoc
Expand All @@ -137,6 +147,8 @@ rustflags
rustfmt
saibatizoku
sandboxed
scanorder
scanstatus
Sched
seckey
slotno
Expand All @@ -153,10 +165,12 @@ testunit
thiserror
timelike
timespec
toobig
toolsets
Traceback
txns
typenum
unfinalized
unlinkat
utimensat
vitss
Expand All @@ -168,8 +182,8 @@ wasmtime
webasm
webassembly
WORKDIR
XPRV
xprivate
XPRV
xprv
xpub
yoroi
2 changes: 1 addition & 1 deletion .github/workflows/stale-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Stale Branches
uses: crs-k/stale-branches@v4.1.0
uses: crs-k/stale-branches@v5.0.0
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
days-before-stale: 30
Expand Down
2 changes: 2 additions & 0 deletions hermes/bin/src/runtime_extensions/hermes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(crate) mod json;
pub(crate) mod kv_store;
pub(crate) mod localtime;
pub(crate) mod logging;
pub(crate) mod sqlite;

/// Advise Runtime Extensions of a new context
pub(crate) fn new_context(ctx: &HermesRuntimeContext) {
Expand All @@ -28,4 +29,5 @@ pub(crate) fn new_context(ctx: &HermesRuntimeContext) {
kv_store::new_context(ctx);
localtime::new_context(ctx);
logging::new_context(ctx);
sqlite::new_context(ctx);
}
81 changes: 81 additions & 0 deletions hermes/bin/src/runtime_extensions/hermes/sqlite/connection/host.rs
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!()
}
}
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) {}
26 changes: 26 additions & 0 deletions hermes/bin/src/runtime_extensions/hermes/sqlite/host.rs
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!()
}
}
11 changes: 11 additions & 0 deletions hermes/bin/src/runtime_extensions/hermes/sqlite/mod.rs
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 hermes/bin/src/runtime_extensions/hermes/sqlite/statement/host.rs
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!()
}
}
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) {}

0 comments on commit 2a01d0e

Please sign in to comment.