3 releases
Uses new Rust 2024
| 0.1.2 | Apr 18, 2026 |
|---|---|
| 0.1.1 | Apr 18, 2026 |
| 0.1.0 | Apr 18, 2026 |
#1737 in Web programming
51 downloads per month
Used in xcelerate
125KB
2K
SLoC
js-protocol
A high-performance, fully type-safe Rust representation of the Chrome DevTools JavaScript Protocol (js_protocol), automatically generated from the official protocol definitions.
🚀 Key Features
- Automated Type Generation: Derived from official V8/Chrome protocol definitions.
- Intelligent Integer Mapping:
i32: Used for coordinates, offsets, and line/column numbers.u64: Used for identifiers, counts, sizes, and ordinals.i64: Default for general integer values.
- Recursive Type Safety: Handles recursive structures via
Box<T>indirection. - Optimized Serialization:
- Uses
serdewithcamelCaserenaming to match the protocol exactly. - Optional fields are omitted from JSON if
Noneto reduce network overhead.
- Uses
- Full Documentation: Protocol descriptions included as Rustdoc comments.
📦 Installation
Add this to your Cargo.toml:
[dependencies]
js-protocol = { version = "0.1.1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
🛠 Usage Example
use js_protocol::runtime::{EvaluateParams, RemoteObject};
fn main() {
// Example: Constructing a 'Runtime.evaluate' request
let params = EvaluateParams {
expression: "console.log('Hello from Rust!')".to_string(),
..Default::default()
};
println!("Serialized request: {:?}", serde_json::to_string(¶ms));
}
Dependencies
~2.4–4MB
~72K SLoC