Skip to content

Instantly share code, notes, and snippets.

mod utils;
use wasm_bindgen::prelude::*;
use serde::*;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
[package]
name = "rust-fn"
version = "0.1.0"
authors = ["Ewan Slater <[email protected]>"]
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[features]
{
"name": "hellofn",
"version": "1.0.0",
"description": "example function",
"main": "func.js",
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@fnproject/fdk": ">=0.0.18",
"@crush-157/rust-fn": ">=0.1.0"
const fdk=require('@fnproject/fdk');
const wasm=require('@crush-157/rust-fn');
fdk.handle(function(input){
let name = 'World';
if (input.name) {
name = input.name;
}
return {'message': wasm.hello_string(name) }
})
const fdk=require('@fnproject/fdk');
const wasm=require('@crush-157/rust-fn');
fdk.handle(function(input){
return wasm.hello_json(input);
})