This commit is contained in:
Michael Zhang 2024-06-21 17:59:41 -05:00
parent 1646db88d1
commit 0a21933795
16 changed files with 408 additions and 139 deletions

348
Cargo.lock generated
View file

@ -60,6 +60,12 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "ambient-authority"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9d4ee0d472d1cd2e28c97dfa124b3d8d992e10eb0a035f33f5d12e3a177ba3b"
[[package]] [[package]]
name = "android-tzdata" name = "android-tzdata"
version = "0.1.1" version = "0.1.1"
@ -623,6 +629,83 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "cap-fs-ext"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fc2d2954524be4866aaa720f008fba9995de54784957a1b0e0119992d6d5e52"
dependencies = [
"cap-primitives",
"cap-std",
"io-lifetimes",
"windows-sys 0.52.0",
]
[[package]]
name = "cap-net-ext"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799c81d79ea9c71a1438efd417c788214bc9e7986046d3710b6bbe60da4d8275"
dependencies = [
"cap-primitives",
"cap-std",
"rustix",
"smallvec",
]
[[package]]
name = "cap-primitives"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00172660727e2d7f808e7cc2bfffd093fdb3ea2ff2ef819289418a3c3ffab5ac"
dependencies = [
"ambient-authority",
"fs-set-times",
"io-extras",
"io-lifetimes",
"ipnet",
"maybe-owned",
"rustix",
"windows-sys 0.52.0",
"winx",
]
[[package]]
name = "cap-rand"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "270f1d341a2afc62604f8f688bee4e444d052b7a74c1458dd3aa7efb47d4077f"
dependencies = [
"ambient-authority",
"rand 0.8.5",
]
[[package]]
name = "cap-std"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cd9187bb3f7478a4c135ea10473a41a5f029d2ac800c1adf64f35ec7d4c8603"
dependencies = [
"cap-primitives",
"io-extras",
"io-lifetimes",
"rustix",
]
[[package]]
name = "cap-time-ext"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91666f31e30c85b1d2ee8432c90987f752c45f5821f5638027b41e73e16a395b"
dependencies = [
"ambient-authority",
"cap-primitives",
"iana-time-zone",
"once_cell",
"rustix",
"winx",
]
[[package]] [[package]]
name = "cargo-platform" name = "cargo-platform"
version = "0.1.8" version = "0.1.8"
@ -1266,13 +1349,22 @@ dependencies = [
"subtle", "subtle",
] ]
[[package]]
name = "dirs"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
dependencies = [
"dirs-sys 0.3.7",
]
[[package]] [[package]]
name = "dirs" name = "dirs"
version = "5.0.1" version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
dependencies = [ dependencies = [
"dirs-sys", "dirs-sys 0.4.1",
] ]
[[package]] [[package]]
@ -1285,6 +1377,17 @@ dependencies = [
"dirs-sys-next", "dirs-sys-next",
] ]
[[package]]
name = "dirs-sys"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]] [[package]]
name = "dirs-sys" name = "dirs-sys"
version = "0.4.1" version = "0.4.1"
@ -1537,6 +1640,17 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
[[package]]
name = "fd-lock"
version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947"
dependencies = [
"cfg-if",
"rustix",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "fdeflate" name = "fdeflate"
version = "0.3.4" version = "0.3.4"
@ -1619,6 +1733,17 @@ dependencies = [
"percent-encoding", "percent-encoding",
] ]
[[package]]
name = "fs-set-times"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "033b337d725b97690d86893f9de22b67b80dcc4e9ad815f348254c38119db8fb"
dependencies = [
"io-lifetimes",
"rustix",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "fs4" name = "fs4"
version = "0.8.4" version = "0.8.4"
@ -2426,6 +2551,22 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "io-extras"
version = "0.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9f046b9af244f13b3bd939f55d16830ac3a201e8a9ba9661bfcb03e2be72b9b"
dependencies = [
"io-lifetimes",
"windows-sys 0.52.0",
]
[[package]]
name = "io-lifetimes"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a611371471e98973dbcab4e0ec66c31a10bc356eeb4d54a0e05eac8158fe38c"
[[package]] [[package]]
name = "ipnet" name = "ipnet"
version = "2.9.0" version = "2.9.0"
@ -2541,6 +2682,13 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "journal"
version = "0.1.0"
dependencies = [
"wasm-bindgen",
]
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.69" version = "0.3.69"
@ -2800,6 +2948,12 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
[[package]]
name = "maybe-owned"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4"
[[package]] [[package]]
name = "md-5" name = "md-5"
version = "0.10.6" version = "0.10.6"
@ -3336,6 +3490,7 @@ dependencies = [
"uuid", "uuid",
"walkdir", "walkdir",
"wasmtime", "wasmtime",
"wasmtime-wasi",
] ]
[[package]] [[package]]
@ -3347,7 +3502,7 @@ dependencies = [
"axum", "axum",
"chrono", "chrono",
"csv", "csv",
"dirs", "dirs 5.0.1",
"futures", "futures",
"itertools 0.13.0", "itertools 0.13.0",
"panorama-core", "panorama-core",
@ -4180,8 +4335,10 @@ checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
dependencies = [ dependencies = [
"bitflags 2.5.0", "bitflags 2.5.0",
"errno", "errno",
"itoa 1.0.11",
"libc", "libc",
"linux-raw-sys", "linux-raw-sys",
"once_cell",
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
@ -4560,6 +4717,15 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "shellexpand"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4"
dependencies = [
"dirs 4.0.0",
]
[[package]] [[package]]
name = "signal-hook-registry" name = "signal-hook-registry"
version = "1.4.2" version = "1.4.2"
@ -5098,6 +5264,22 @@ dependencies = [
"version-compare", "version-compare",
] ]
[[package]]
name = "system-interface"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b858526d22750088a9b3cf2e3c2aacebd5377f13adeec02860c30d09113010a6"
dependencies = [
"bitflags 2.5.0",
"cap-fs-ext",
"cap-std",
"fd-lock",
"io-lifetimes",
"rustix",
"windows-sys 0.52.0",
"winx",
]
[[package]] [[package]]
name = "tantivy" name = "tantivy"
version = "0.22.0" version = "0.22.0"
@ -5948,7 +6130,7 @@ dependencies = [
"cocoa", "cocoa",
"core-graphics", "core-graphics",
"crossbeam-channel", "crossbeam-channel",
"dirs", "dirs 5.0.1",
"libappindicator", "libappindicator",
"muda", "muda",
"objc", "objc",
@ -6375,9 +6557,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "786d8b5e7a4d54917c5ebe555b9667337e5f93383f49bddaaeec2eba68093b45" checksum = "786d8b5e7a4d54917c5ebe555b9667337e5f93383f49bddaaeec2eba68093b45"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait",
"bumpalo", "bumpalo",
"cc", "cc",
"cfg-if", "cfg-if",
"encoding_rs",
"hashbrown 0.14.5", "hashbrown 0.14.5",
"indexmap 2.2.6", "indexmap 2.2.6",
"libc", "libc",
@ -6392,6 +6576,7 @@ dependencies = [
"postcard", "postcard",
"psm", "psm",
"rustix", "rustix",
"semver",
"serde", "serde",
"serde_derive", "serde_derive",
"smallvec", "smallvec",
@ -6400,11 +6585,14 @@ dependencies = [
"wasmparser", "wasmparser",
"wasmtime-asm-macros", "wasmtime-asm-macros",
"wasmtime-component-macro", "wasmtime-component-macro",
"wasmtime-component-util",
"wasmtime-cranelift", "wasmtime-cranelift",
"wasmtime-environ", "wasmtime-environ",
"wasmtime-fiber",
"wasmtime-jit-icache-coherence", "wasmtime-jit-icache-coherence",
"wasmtime-slab", "wasmtime-slab",
"wasmtime-versioned-export-macros", "wasmtime-versioned-export-macros",
"wasmtime-winch",
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
@ -6481,9 +6669,25 @@ dependencies = [
"wasm-encoder", "wasm-encoder",
"wasmparser", "wasmparser",
"wasmprinter", "wasmprinter",
"wasmtime-component-util",
"wasmtime-types", "wasmtime-types",
] ]
[[package]]
name = "wasmtime-fiber"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ded58eb2d1bf0dcd2182d0ccd7055c4b10b50d711514f1d73f61515d0fa829d"
dependencies = [
"anyhow",
"cc",
"cfg-if",
"rustix",
"wasmtime-asm-macros",
"wasmtime-versioned-export-macros",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "wasmtime-jit-icache-coherence" name = "wasmtime-jit-icache-coherence"
version = "22.0.0" version = "22.0.0"
@ -6526,6 +6730,54 @@ dependencies = [
"syn 2.0.67", "syn 2.0.67",
] ]
[[package]]
name = "wasmtime-wasi"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8abb1301089ed8e0b4840f539cba316a73ac382090f1b25d22d8c8eed8df49c7"
dependencies = [
"anyhow",
"async-trait",
"bitflags 2.5.0",
"bytes",
"cap-fs-ext",
"cap-net-ext",
"cap-rand",
"cap-std",
"cap-time-ext",
"fs-set-times",
"futures",
"io-extras",
"io-lifetimes",
"once_cell",
"rustix",
"system-interface",
"thiserror",
"tokio",
"tracing",
"url",
"wasmtime",
"wiggle",
"windows-sys 0.52.0",
]
[[package]]
name = "wasmtime-winch"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed4db238a0241df2d15f79ad17b3a37a27f2ea6cb885894d81b42ae107544466"
dependencies = [
"anyhow",
"cranelift-codegen",
"gimli 0.28.1",
"object",
"target-lexicon",
"wasmparser",
"wasmtime-cranelift",
"wasmtime-environ",
"winch-codegen",
]
[[package]] [[package]]
name = "wasmtime-wit-bindgen" name = "wasmtime-wit-bindgen"
version = "22.0.0" version = "22.0.0"
@ -6538,6 +6790,15 @@ dependencies = [
"wit-parser", "wit-parser",
] ]
[[package]]
name = "wast"
version = "35.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68"
dependencies = [
"leb128",
]
[[package]] [[package]]
name = "wayland-sys" name = "wayland-sys"
version = "0.31.2" version = "0.31.2"
@ -6664,6 +6925,48 @@ dependencies = [
"wasite", "wasite",
] ]
[[package]]
name = "wiggle"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29830e5d01c182d24b94092c697aa7ab0ee97d22e78a2bf40ca91eae6ebca5c2"
dependencies = [
"anyhow",
"async-trait",
"bitflags 2.5.0",
"thiserror",
"tracing",
"wasmtime",
"wiggle-macro",
]
[[package]]
name = "wiggle-generate"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "557567f2793508760cd855f7659b7a0b9dc4dbc451f53f1415d6943a15311ade"
dependencies = [
"anyhow",
"heck 0.4.1",
"proc-macro2",
"quote",
"shellexpand",
"syn 2.0.67",
"witx",
]
[[package]]
name = "wiggle-macro"
version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc26129a8aea20b62c961d1b9ab4a3c3b56b10042ed85d004f8678af0f21ba6e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.67",
"wiggle-generate",
]
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -6695,6 +6998,23 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "winch-codegen"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85c6915884e731b2db0d8cf08cb64474cb69221a161675fd3c135f91febc3daa"
dependencies = [
"anyhow",
"cranelift-codegen",
"gimli 0.28.1",
"regalloc2",
"smallvec",
"target-lexicon",
"wasmparser",
"wasmtime-cranelift",
"wasmtime-environ",
]
[[package]] [[package]]
name = "window-vibrancy" name = "window-vibrancy"
version = "0.5.0" version = "0.5.0"
@ -7056,6 +7376,16 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "winx"
version = "0.36.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9643b83820c0cd246ecabe5fa454dd04ba4fa67996369466d0747472d337346"
dependencies = [
"bitflags 2.5.0",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "wit-parser" name = "wit-parser"
version = "0.209.1" version = "0.209.1"
@ -7074,6 +7404,18 @@ dependencies = [
"wasmparser", "wasmparser",
] ]
[[package]]
name = "witx"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b"
dependencies = [
"anyhow",
"log",
"thiserror",
"wast",
]
[[package]] [[package]]
name = "wry" name = "wry"
version = "0.40.1" version = "0.40.1"

View file

@ -1,2 +1,2 @@
workspace.resolver = "2" workspace.resolver = "2"
workspace.members = ["crates/*", "ui/src-tauri"] workspace.members = [ "apps/journal","crates/*", "ui/src-tauri"]

10
apps/journal/Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "journal"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
wasm-bindgen = "0.2.92"

View file

@ -1,22 +0,0 @@
{
"targets": {
"debug": {
"outFile": "build/debug.wasm",
"textFile": "build/debug.wat",
"sourceMap": true,
"debug": true
},
"release": {
"outFile": "build/release.wasm",
"textFile": "build/release.wat",
"sourceMap": true,
"optimizeLevel": 3,
"shrinkLevel": 0,
"converge": false,
"noAssert": false
}
},
"options": {
"bindings": "esm"
}
}

View file

@ -1,4 +0,0 @@
export function install(): i32 {
console.log("Hellosu!");
return 0;
}

View file

@ -1,6 +0,0 @@
{
"extends": "assemblyscript/std/assembly.json",
"include": [
"./**/*.ts"
]
}

View file

@ -1,2 +0,0 @@
*
!.gitignore

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script type="module">
import { add } from "./build/release.js";
document.body.innerText = add(1, 2);
</script>
</head>
<body></body>
</html>

View file

@ -3,4 +3,4 @@ version: 0.1.0
panorama_version: 0.1.0 panorama_version: 0.1.0
description: Note taking app description: Note taking app
installer_path: build/release.wasm installer_path: pkg/journal_bg.wasm

View file

@ -1,54 +0,0 @@
{
"name": "journal",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "journal",
"version": "0.1.0",
"license": "ISC",
"devDependencies": {
"assemblyscript": "^0.27.27"
}
},
"node_modules/assemblyscript": {
"version": "0.27.27",
"resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.27.27.tgz",
"integrity": "sha512-z4ijXsjjk3uespEeCWpO1K2GQySc6bn+LL5dL0tsC2VXNYKFnKDmAh3wefcKazxXHFVhYlxqNfyv96ajaQyINQ==",
"dev": true,
"dependencies": {
"binaryen": "116.0.0-nightly.20240114",
"long": "^5.2.1"
},
"bin": {
"asc": "bin/asc.js",
"asinit": "bin/asinit.js"
},
"engines": {
"node": ">=16",
"npm": ">=7"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/assemblyscript"
}
},
"node_modules/binaryen": {
"version": "116.0.0-nightly.20240114",
"resolved": "https://registry.npmjs.org/binaryen/-/binaryen-116.0.0-nightly.20240114.tgz",
"integrity": "sha512-0GZrojJnuhoe+hiwji7QFaL3tBlJoA+KFUN7ouYSDGZLSo9CKM8swQX8n/UcbR0d1VuZKU+nhogNzv423JEu5A==",
"dev": true,
"bin": {
"wasm-opt": "bin/wasm-opt",
"wasm2js": "bin/wasm2js"
}
},
"node_modules/long": {
"version": "5.2.3",
"resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz",
"integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==",
"dev": true
}
}
}

View file

@ -1,26 +0,0 @@
{
"name": "journal",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node tests",
"asbuild:debug": "asc assembly/index.ts --target debug",
"asbuild:release": "asc assembly/index.ts --target release",
"asbuild": "npm run asbuild:debug && npm run asbuild:release",
"start": "npx serve ."
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"assemblyscript": "^0.27.27"
},
"type": "module",
"exports": {
".": {
"import": "./build/release.js",
"types": "./build/release.d.ts"
}
}
}

View file

@ -1,3 +0,0 @@
pub fn main() {
let y = 1 + 2;
}

23
apps/journal/src/lib.rs Normal file
View file

@ -0,0 +1,23 @@
use std::ffi::CString;
use wasm_bindgen::prelude::wasm_bindgen;
mod sys {
use std::ffi::c_char;
extern "C" {
pub fn register_endpoint(url: *const c_char);
}
}
pub fn register_endpoint(url: impl AsRef<str>) {
let url = CString::new(url.as_ref()).unwrap();
let result = unsafe { sys::register_endpoint(url.into_raw()) };
println!("Result: {:?}", result);
}
#[wasm_bindgen]
pub fn install() -> i32 {
register_endpoint("/hello");
123
}

View file

@ -1,4 +0,0 @@
import assert from "assert";
import { add } from "../build/debug.js";
assert.strictEqual(add(1, 2), 3);
console.log("ok");

View file

@ -31,6 +31,7 @@ wasmtime = { version = "22.0.0", default-features = false, features = [
"runtime", "runtime",
"cranelift", "cranelift",
] } ] }
wasmtime-wasi = "22.0.0"
[dependencies.async-imap] [dependencies.async-imap]
version = "0.9.7" version = "0.9.7"

View file

@ -8,7 +8,10 @@ use std::{
use anyhow::{Context as _, Result}; use anyhow::{Context as _, Result};
use serde_yaml::Value; use serde_yaml::Value;
use wasmtime::{Config, Engine, Linker, Module, Store}; use wasmtime::{
Caller, Config, Engine, Linker, Memory, MemoryType, Module, Store,
};
use wasmtime_wasi::WasiCtxBuilder;
use crate::AppState; use crate::AppState;
@ -101,8 +104,29 @@ impl AppState {
let config = Config::new(); let config = Config::new();
let engine = Engine::new(&config)?; let engine = Engine::new(&config)?;
let module = Module::new(&engine, &installer_program)?; let module = Module::new(&engine, &installer_program)?;
let linker = Linker::new(&engine);
let mut store: Store<u32> = Store::new(&engine, 4); let wasi = WasiCtxBuilder::new().inherit_stdio().inherit_args().build();
let mut store: Store<_> = Store::new(&engine, wasi);
let ty = MemoryType::new64(0, None);
let memory = Memory::new(&mut store, ty)?;
let mut linker = Linker::new(&engine);
linker.func_wrap(
"env",
"register_endpoint",
|caller: Caller<'_, _>, param: i32| {
println!("Got {} , from WebAssembly", param);
// println!("my host state is: {}", caller.data());
},
)?;
linker.func_wrap(
"env",
"abort",
|caller: Caller<'_, _>, param: i32, _: i32, _: i32, _: i32| {
println!("Oops, aborted.");
},
)?;
let instance = linker.instantiate(&mut store, &module)?; let instance = linker.instantiate(&mut store, &module)?;
let hello = instance.get_typed_func::<(), i32>(&mut store, "install")?; let hello = instance.get_typed_func::<(), i32>(&mut store, "install")?;
hello.call(&mut store, ())?; hello.call(&mut store, ())?;