Readme

This val is written in Rust!

See This Gist for how to build rust vals. And https://www.val.town/v/saolsen/use_example_rust_val for an example of how to use it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import * as base64 from "https://deno.land/std/encoding/base64.ts";
const bytes = base64.decodeBase64(
// base64 encoded wasm module
"AGFzbQEAAAABDwNgAn9/AGAAAGACf38BfwI3ARhfX3diaW5kZ2VuX3BsYWNlaG9sZGVyX18aX193YmdfbG9nXzA4ODUwZDZkNGQ5MWY0YzkAAAMDAgECBQMBABEHHAMGbWVtb3J5AgADYWRkAAIJc2F5X2hlbGxvAAEKFQILAEGAgMAAQRoQAAsHACAAIAFqCwsjAQBBgIDAAAsaSGVsbG8gZnJvbSBSdXN0LCBpdCB3b3JrcyEAbwlwcm9kd
);
let imports: any = {};
imports["__wbindgen_placeholder__"] = imports;
let wasm;
const { TextDecoder } = globalThis;
let cachedTextDecoder = new TextDecoder("utf-8", {
ignoreBOM: true,
fatal: true,
});
cachedTextDecoder.decode();
let cachedUint8Memory0 = null;
function getUint8Memory0() {
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8Memory0;
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
/** */
export const say_hello = (imports.say_hello = function() {
wasm.say_hello();
});
/**
* @param {number} x
* @param {number} y
* @returns {number}
*/
export const add = (imports.add = function(x, y) {
const ret = wasm.add(x, y);
return ret;
});
export const __wbg_log_08850d6d4d91f4c9 = (imports.__wbg_log_08850d6d4d91f4c9 = function(arg0, arg1) {
console.log(getStringFromWasm0(arg0, arg1));
});
const wasmModule = new WebAssembly.Module(bytes);
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
wasm = wasmInstance.exports;
export const __wasm = (imports.__wasm = wasm);
export default imports;
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.