Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust and WebAssembly Demo for SCF

Rust Demo

## 静态链接编译
RUSTFLAGS='-C target-feature=+crt-static' cargo build --target=x86_64-unknown-linux-gnu --release
## 复制编译好的文件
cp target/x86_64-unknown-linux-gnu/release/scf-server pkg/bootstrap
cd pkg
## 给文件添加执行权限
chmod 755 ./bootstrap
## 打包zip
zip pkg.zip bootstrap

通过 Custom Runtime 执行 bootstrap

Wasm Demo

curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
wasm-pack build --target nodejs --release
zip -r pkg.zip index.js pkg  -x "*.git*"

通过 Nodejs Runtime 执行:

const wasm = require("./pkg/rust_scf_facefinder");

exports.main_handler = async (event, context, callback) => {
  var body = event['body']
  var finder_result = wasm.process_event(body);

  return {
    isBase64Encoded: false,
    statusCode: 200,
    headers: { 'Content-Type': 'application/json' },
    body: finder_result,
  }
}

引用

About

腾讯云函数(SCF)人脸检测 - Rust & WebAssembly

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages