npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rust-ipc

v1.0.1

Published

**rust-ipc** is a library that enables inter-process duplex JSON-RPC communications with executables generated by `rustc`.

Downloads

3

Readme

rust-ipc

rust-ipc is a library that enables inter-process duplex JSON-RPC communications with executables generated by rustc.

rust-ipc is not opinionated about the data layout and allows scalar types to be passed across the process.

rust-ipc extends Node's EventEmitter API to enable bi-directional communication with the executable's process.

Warning: Due to API mismatches, bi-directional communications are not possible. Only Rust binaries can emit data.

Motivation

Maintenance of Rust bindings to Node via N-API or the Node Addon API is challenging due to the internal usage of node-gyp for the latter.

FFI bindings via node-ffi, which uses the libffi C++ library, also has its own set of maintenance issues, although considerably more maintainable than node-gyp, albeit a substantial performance overhead for FFI calls.

With both the solutions above, I/O is not free. Creating and keeping alive HTTP servers or file watchers is complicated or impossible (std::ffi::c_void cannot be passed across threads). Given that many server implementations use threads, it becomes difficult to write I/O Node applications with native bindings, effectively rendering both solutions (node-gyp and node-ffi) just as featureless as WebAssembly in Node.

My presumption is that rust-ipc does not rank against both the above solutions in terms of performance, which is not part of the motivations. Maintenance is the primary goal. A separate process is created to execute the binary and run bi-directional operations.

Optionally, a user can ship a platform specific binary which is then fed to rust-ipc's API. Such logic is left to the user and rust-ipc handles communications only.

Installation

$ npm install rust-ipc

Usage

Before proceeding to examples, it is important to understand that the Rust binary is virtually sandboxed and hence expected to use println!() calls to the stdout in order for rust-ipc to catch any incoming data. Ensure that no included crates print any trace messages to the console.

Additionally, the spawn function from child_process is used, so the process is non-blocking and can live as long as the Rust executable alive. For instance, if a watcher is used, the

In this example, we'll send some data from Node, modify it in Rust, then send it back.

import ipc from "rust-ipc";

interface Person {
  name: string;
  age: number;
  hobby: string;
}

ipc("./path/to/executable.exe")
  .on("data", (data: string) => {
    const person: Person = JSON.parse(data);
    console.table(...p);
  })
  .end();

License

MIT License © Saddam M.