Improve docs in core (#2049)

This commit is contained in:
Ryan Dahl 2019-04-04 09:35:52 -04:00 committed by GitHub
parent 4520e5812e
commit 0a26230a87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 15 deletions

View file

@ -7,6 +7,8 @@ edition = "2018"
description = "A secure JavaScript/TypeScript runtime built with V8, Rust, and Tokio" description = "A secure JavaScript/TypeScript runtime built with V8, Rust, and Tokio"
authors = ["The deno authors <bertbelder@nodejs.org>"] authors = ["The deno authors <bertbelder@nodejs.org>"]
license = "MIT" license = "MIT"
readme = "README.md"
repository = "https://github.com/denoland/deno"
[lib] [lib]
path = "lib.rs" path = "lib.rs"

16
core/README.md Normal file
View file

@ -0,0 +1,16 @@
# Deno Core
This Rust crate contains the essential V8 bindings for Deno's command-line
interface (Deno CLI). The main abstraction here is the Isolate which proivdes a
way to execute JavaScript. The Isolate is modeled as a
`Future<Item=(), Error=JSError>` which completes once all of its ops have
completed. The user must define what an Op is by implementing the `Behavior`
trait, and by doing so define any "built-in" functionality that would be
provided by the VM. Ops are triggered by `Deno.core.dispatch()`.
Documentation for this crate is thin at the moment. Please see
[http_bench.rs](https://github.com/denoland/deno/blob/master/core/http_bench.rs)
as a simple example of usage.
TypeScript support and a lot of other functionality is not available at this
layer. See the [cli](https://github.com/denoland/deno/tree/master/cli) for that.

View file

@ -68,8 +68,8 @@ pub trait Behavior {
/// Isolate is created. /// Isolate is created.
fn startup_data(&mut self) -> Option<StartupData>; fn startup_data(&mut self) -> Option<StartupData>;
/// Called whenever Deno.core.send() is called in JavaScript. zero_copy_buf /// Called whenever Deno.core.dispatch() is called in JavaScript. zero_copy_buf
/// corresponds to the second argument of Deno.core.send(). /// corresponds to the second argument of Deno.core.dispatch().
fn dispatch( fn dispatch(
&mut self, &mut self,
control: &[u8], control: &[u8],
@ -82,9 +82,9 @@ pub trait Behavior {
/// Tokio. The Isolate future complete when there is an error or when all /// Tokio. The Isolate future complete when there is an error or when all
/// pending ops have completed. /// pending ops have completed.
/// ///
/// Ops are created in JavaScript by calling Deno.core.send(), and in Rust by /// Ops are created in JavaScript by calling Deno.core.dispatch(), and in Rust
/// implementing Behavior::dispatch. An Op corresponds exactly to a Promise in /// by implementing deno::Behavior::dispatch. An Op corresponds exactly to a
/// JavaScript. /// Promise in JavaScript.
pub struct Isolate<B: Behavior> { pub struct Isolate<B: Behavior> {
libdeno_isolate: *const libdeno::isolate, libdeno_isolate: *const libdeno::isolate,
shared_libdeno_isolate: Arc<Mutex<Option<*const libdeno::isolate>>>, shared_libdeno_isolate: Arc<Mutex<Option<*const libdeno::isolate>>>,

View file

@ -50,7 +50,7 @@ Deno provides <a href="https://github.com/denoland/deno_std">a set of reviewed
- File system and network access can be controlled in order to run sandboxed - File system and network access can be controlled in order to run sandboxed
code. Access between V8 (unprivileged) and Rust (privileged) is only done via code. Access between V8 (unprivileged) and Rust (privileged) is only done via
serialized messages defined in this serialized messages defined in this
[flatbuffer](https://github.com/denoland/deno/blob/master/src/msg.fbs). This [flatbuffer](https://github.com/denoland/deno/blob/master/cli/msg.fbs). This
makes it easy to audit. For example, to enable write access use the flag makes it easy to audit. For example, to enable write access use the flag
`--allow-write` or for network access `--allow-net`. `--allow-write` or for network access `--allow-net`.
@ -705,21 +705,18 @@ Current executable set to '../deno/target/debug/deno' (x86_64).
(lldb) r (lldb) r
``` ```
### libdeno ### Deno Core
deno's privileged side will primarily be programmed in Rust. However there will The core binding layer for Deno. It is released as a
be a small C API that wraps V8 to 1) define the low-level message passing [standalone crate](https://crates.io/crates/deno). Inside of core is V8 itself,
semantics, 2) provide a low-level test target, 3) provide an ANSI C API binding with a binding API called "libdeno". See the crate documentation for more
interface for Rust. V8 plus this C API is called "libdeno" and the important details.
bits of the API is specified here:
[deno.h](https://github.com/denoland/deno/blob/master/libdeno/deno.h)
[libdeno.ts](https://github.com/denoland/deno/blob/master/js/libdeno.ts)
### Flatbuffers ### Flatbuffers
We use Flatbuffers to define common structs and enums between TypeScript and We use Flatbuffers to define common structs and enums between TypeScript and
Rust. These common data structures are defined in Rust. These common data structures are defined in
[msg.fbs](https://github.com/denoland/deno/blob/master/src/msg.fbs) [msg.fbs](https://github.com/denoland/deno/blob/master/cli/msg.fbs)
### Updating prebuilt binaries ### Updating prebuilt binaries