0.9.3 • Published 2 years ago

wtools-rust v0.9.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Rust binary integration in Javascript

Contact

  • Eduardo Sánchez
  • whipshout@gmail.com

Info

  • We can integrate Rust with Node through native addons, as we would with C++.
  • To do this, we have to interact with Javascript through C. We compile a Rust library using C interfaces and bindings. The library is in different formats depending on the operating system.
  • To do all the hard work, we use the crate called NAPI, which is responsible for making the interfaces and bindings with C and exporting the functions for use in Javascript.

NAPI crate

How to use the native addon

  • Create/open a javascript/typescript project.
  • Install the package using npm install wtools-rust. The main package will install the right dependency for your OS automatically.
  • Import the package and call the function (Typescript snippet, functions have ts types generated during the compilation):
import { uuid } from "./index";

const uuidRandom = uuid() // Generate random uuid

const uuidInput = uuid('asdfadfsadsf') // Generate uuid using hash SHA256 with the input text
0.9.3

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.9.0

2 years ago

0.8.5

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago