Getting Started
Rustyscript - Effortless JS Integration for Rust
rustyscript provides a quick and simple way to integrate a runtime javascript or typescript component from within Rust.
It uses the v8 engine through the deno_core
crate, and aims to be as simple as possible to use without sacrificing flexibility or performance.
I also have attempted to abstract away the v8 engine details so you can for the most part operate directly on rust types.
Core Principles
Sandboxed
By default, the code being run is entirely sandboxed from the host, having no filesystem or network access. extensions can be added to grant additional capabilities that may violate sandboxing
Flexible
The runtime is designed to be as flexible as possible, allowing you to modify capabilities, the module loader, and more.
- Asynchronous JS is fully supported, and the runtime can be configured to run in a multithreaded environment.
- Typescript is supported, and will be transpired into JS for execution.
- Node JS is supported experimentally, but is not yet fully compatible See the NodeJS Compatibility section
Extension Features
The crate includes the following features that can be turned on or off as needed:
For a full list of available extensions, see the extensions section.
safe_extensions
ON BY DEFAULT
console
crypto
url
web_stub
Deno extensions that maintain a secure, sandboxed runtime environment
io_extensions
web
cache
cron
ffi
fs
io
kv
webgpu
Deno extensions that grant runtimes access to the file system (but may also grant some level of network access - use caution)
network_extensions
broadcast_channel
http
web
websocket
webstorage
Deno extensions that grant runtimes access to system network resources
node_experimental
safe_extensions
io_extensions
network_extensions
Experimental NodeJS compatibility
Javascript Isolation Features
url_import
Enables executed Javascript to include modules from arbitrary URLs
fs_import
Enables executed Javascript to include modules from the file system, without needing to load them from rust first
Additional Features
worker
ON BY DEFAULT
Enables the multithreadedworker
API
snapshot_builder
Enables thesnapshot_builder
API