Deno Core 项目教程
deno_coreThe core engine at the heart of Deno项目地址:https://gitcode.com/gh_mirrors/de/deno_core
1. 项目目录结构及介绍
Deno Core 项目的目录结构如下:
deno_core/
├── core/
│ ├── dcore/
│ ├── ops/
│ ├── serde_v8/
│ ├── testing/
│ └── tools/
├── dprint.json
├── .gitattributes
├── .gitignore
├── rustfmt.toml
├── ARCHITECTURE.md
├── Cargo.lock
├── Cargo.toml
├── LICENSE.md
├── README.md
└── rust-toolchain.toml
目录介绍
-
core/: 核心代码目录,包含项目的核心逻辑和功能实现。
- dcore/: 核心逻辑的具体实现。
- ops/: 操作相关的代码。
- serde_v8/: 与 V8 引擎的序列化和反序列化相关的代码。
- testing/: 测试代码。
- tools/: 项目使用的工具代码。
-
dprint.json: 代码格式化配置文件。
-
.gitattributes: Git 属性配置文件。
-
.gitignore: Git 忽略文件配置。
-
rustfmt.toml: Rust 代码格式化配置文件。
-
ARCHITECTURE.md: 项目架构文档。
-
Cargo.lock: Cargo 依赖锁定文件。
-
Cargo.toml: Cargo 项目配置文件。
-
LICENSE.md: 项目许可证文件。
-
README.md: 项目介绍和使用说明。
-
rust-toolchain.toml: Rust 工具链配置文件。
2. 项目启动文件介绍
Deno Core 项目的启动文件是 core/dcore/mod.rs
。该文件是项目的入口文件,负责初始化核心逻辑和启动项目。
启动文件内容
// core/dcore/mod.rs
pub mod ops;
pub mod serde_v8;
pub mod testing;
pub mod tools;
// 初始化逻辑
fn main() {
// 初始化代码
}
3. 项目配置文件介绍
Cargo.toml
Cargo.toml
是 Rust 项目的配置文件,定义了项目的依赖、构建选项和其他配置。
[package]
name = "deno_core"
version = "0.307.0"
edition = "2018"
[dependencies]
anyhow = "^1"
bincode = "^1"
bit-set = "^0.5.3"
bit-vec = "^0.6.3"
bytes = ">=1.6.0"
cooked-waker = "^5"
deno_core_icudata = "^0.0.73"
deno_ops = "^0.183.0"
deno_unsync = "^0.4.0"
futures = "^0.3.21"
libc = "^0.2.126"
memoffset = ">=0.9"
parking_lot = "^0.12.0"
percent-encoding = "^2.3.0"
pin-project = "^1"
serde = "^1"
serde_json = "^1"
serde_v8 = "^0.216.0"
smallvec = "^1.8"
sourcemap = "^8"
static_assertions = "^1"
tokio = "^1"
url = "^2"
v8 = "^0.105.0"
[dev-dependencies]
bencher = "^0.1"
criterion = "^0.5"
deno_ast = "=0.40"
fastrand = "^2"
pretty_assertions = "^1.3.0"
rstest = "^0"
twox-hash = "^1.6.3"
unicycle = "^0"
rustfmt.toml
rustfmt.toml
是 Rust 代码格式化工具的配置文件,定义了代码格式化的规则。
max_width = 100
tab_spaces = 4
dprint.json
dprint.json
是代码格式化工具 dprint 的配置文件。
{
"lineWidth": 100,
"useTabs": false,
"indentWidth": 4
}
rust-toolchain.toml
rust-toolchain.toml
是 Rust 工具链的配置文件,定义了项目使用的 Rust 版本。
[toolchain]
channel = "stable"
通过以上配置文件,可以确保项目的依赖管理、代码格式化和工具链配置的一致性。
deno_coreThe core engine at the heart of Deno项目地址:https://gitcode.com/gh_mirrors/de/deno_core