All Projects → matiasinsaurralde → Rust V8worker2

matiasinsaurralde / Rust V8worker2

Licence: mit
Minimal Rust binding to V8 (based on ry/libv8worker2)

Programming Languages

javascript
184084 projects - #8 most used programming language
rust
11053 projects
js
455 projects

Labels

Projects that are alternatives of or similar to Rust V8worker2

Chineseutil
PHP 中文工具包,支持汉字转拼音、拼音分词、简繁互转、数字、金额大写;QQ群:17916227
Stars: ✭ 413 (+1151.52%)
Mutual labels:  ffi
Core
MetaCall: The ultimate polyglot programming experience.
Stars: ✭ 596 (+1706.06%)
Mutual labels:  ffi
Hcwiid
Haskell binding for CWiid (wiimote)
Stars: ✭ 7 (-78.79%)
Mutual labels:  ffi
Rust Cpp
Embed C++ directly inside your rust code!
Stars: ✭ 502 (+1421.21%)
Mutual labels:  ffi
Dart native
Write iOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.
Stars: ✭ 564 (+1609.09%)
Mutual labels:  ffi
Rust Python Example
Example of using Rust to Extend Python
Stars: ✭ 699 (+2018.18%)
Mutual labels:  ffi
V8py
Write Python APIs, then call them from JavaScript using the V8 engine.
Stars: ✭ 399 (+1109.09%)
Mutual labels:  v8
V8 Cffi
Embed the V8 Javascript Interpreter into Python
Stars: ✭ 31 (-6.06%)
Mutual labels:  v8
V8.dev
The source code of v8.dev, the official website of the V8 project.
Stars: ✭ 567 (+1618.18%)
Mutual labels:  v8
Php Ffi Examples
Runnable examples to learn how PHP FFI works
Stars: ✭ 26 (-21.21%)
Mutual labels:  ffi
React Native V8
Opt-in V8 runtime for React Native Android
Stars: ✭ 514 (+1457.58%)
Mutual labels:  v8
Go Cshared Examples
Calling Go Functions from Other Languages using C Shared Libraries
Stars: ✭ 541 (+1539.39%)
Mutual labels:  ffi
Liquidcore
Node.js virtual machine for Android and iOS
Stars: ✭ 765 (+2218.18%)
Mutual labels:  v8
Haskellr
The full power of R in Haskell.
Stars: ✭ 491 (+1387.88%)
Mutual labels:  ffi
V8 Bailout Reasons
🔧 A list of Crankshaft bailout reasons with examples
Stars: ✭ 861 (+2509.09%)
Mutual labels:  v8
Pyo3
Rust bindings for the Python interpreter
Stars: ✭ 5,110 (+15384.85%)
Mutual labels:  ffi
Cxx.jl
The Julia C++ Interface
Stars: ✭ 620 (+1778.79%)
Mutual labels:  ffi
Zion
A statically-typed strictly-evaluated garbage-collected readable programming language.
Stars: ✭ 33 (+0%)
Mutual labels:  ffi
Monomorphist
monomorphist - a JavaScript performance companion
Stars: ✭ 30 (-9.09%)
Mutual labels:  v8
Cef4delphi
CEF4Delphi is an open source project to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC for Windows, Linux and MacOS.
Stars: ✭ 785 (+2278.79%)
Mutual labels:  v8

rust-v8worker2

Build Status

This is a minimal binding between Rust (and V8 JavaScript. Basic concept is to only expose two methods to JavaScript: send and receive.

Based on ry/v8worker2.

Usage

Add this to your Config.toml:

[dependencies]
v8worker2 = { git = "https://github.com/matiasinsaurralde/rust-v8worker2" }

Note: If you include this repository as a dependency, the cargo build command may take some time to fetch and build V8, on my box it takes around 20 minutes. There's a condition that prevents this build step to run if the library is already present. If detailed build logging is required consider using cargo build -vv.

To use the crate:

extern crate v8worker2;
extern crate bytes;

use v8worker2::worker::Worker as Worker;

fn main() {
    // Initialize V8 (V8::InitializePlatform and V8::Initialize):
    let mut _handler = v8worker2::new_handler();
    _handler.init();

    // Setup a callback that receives bytes and returns boxed bytes:
    let cb = |incoming_data: bytes::Bytes| -> Box<bytes::Bytes> {
        println!("Getting data from V8, length is {}", incoming_data.len());

        // Send some stuff to V8, this is not in use at the moment but we still require it:
        let data = Bytes::from(&b"reply"[..]);
        Box::new(data)
    };

    // Initialize a worker with the callback:
    let mut worker = Worker::new(cb);

    // Send an empty ArrayBuffer (V8 -> Rust), the callback will print the length of it:
    worker.load("code.js", "V8Worker2.send(new ArrayBuffer(10))".to_string());
}

Setup

If you want to see the detailed output of the V8 build, run:

$ ./build.py --enable-ccache

Otherwise you may run cargo build directly, the V8 build steps are part of build.rs.

To run the tests, use cargo test -- --nocapture.

Requirements

  • Python (required by the build script)
  • C/C++ compiler
  • pkg-config
  • ccache (OS X: brew install ccache)
  • Git
  • Rust 1.26 or newer

Supported platforms

My development box runs OS X, the CI environment runs Linux. These two platforms should be ok.

License

This project contains code written by Ryan Dahl, I'm using the same license for my additional Rust codebase:

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].