Module neon::borrow[][src]

Expand description

Provides temporary access to JavaScript typed arrays.

Typed Arrays

JavaScript’s typed arrays are objects that allow reading and writing raw binary data in memory.

Typed arrays are managed with the ArrayBuffer type, which controls the storage of the underlying data buffer, and several typed views for managing access to the buffer. Neon provides access to the ArrayBuffer class with the JsArrayBuffer type.

Node also provides a Buffer type, which is built on top of ArrayBuffer and provides additional functionality. Neon provides access to the Buffer class with the JsBuffer type.

Many of Node’s I/O APIs work with these types, and they can also be used for compact in-memory data structures, which can be shared efficiently between JavaScript and Rust without copying.

Borrowing

Neon makes it possible to borrow temporary access to the internal memory of a typed array by pausing execution of JavaScript with a Lock and returning a reference to a BinaryData struct. The Borrow and BorrowMut traits provide the methods for borrowing this typed array data.

Structs

Ref

An immutable reference to the contents of a borrowed JS value.

RefMut

A mutable reference to the contents of a borrowed JS value.

Enums

LoanError

An error produced by a failed loan in the Borrow or BorrowMut traits.

Traits

Borrow

A trait for JS values whose internal contents can be borrowed immutably by Rust while the JS engine is locked.

BorrowMut

A trait for JS values whose internal contents can be borrowed mutably by Rust while the JS engine is locked.