2 unstable releases
Uses new Rust 2024
| 0.2.0 | Nov 18, 2025 |
|---|---|
| 0.1.0 | Oct 28, 2025 |
#21 in #dap
34 downloads per month
215KB
2.5K
SLoC
emmy_dap_types
A Rust implementation of the Debug Adapter Protocol (DAP) types and utilities.
Overview
This project is a fork of dap-rs with additional improvements and cross-editor compatibility enhancements.
emmy_dap_types provides strongly-typed Rust structures for the Debug Adapter Protocol, making it easy to build debug adapters or debug clients in Rust.
Features
- ✅ Complete DAP Types - Full implementation of DAP specification types
- ✅ Cross-Editor Compatible - Works seamlessly with VS Code, IntelliJ IDEA, Zed, and other DAP clients
- ✅ Flexible Deserialization - Custom deserializer handles different client behaviors (empty
argumentsobjects vs. missing fields) - ✅ Type-Safe - Leverages Rust's type system for compile-time correctness
- ✅ Serde Support - JSON serialization/deserialization using
serde
Installation
Add this to your Cargo.toml:
[dependencies]
emmy_dap_types = "0.1"
Usage
use emmy_dap_types::prelude::*;
use std::io::{stdin, stdout};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let input = stdin();
let output = stdout();
let mut server = Server::new(input, output);
loop {
let req: Request = server.poll_request()?;
match req.command {
Command::Initialize(args) => {
// Handle initialize request
let response = req.success(ResponseBody::Initialize(Some(Capabilities {
supports_configuration_done_request: Some(true),
// ... other capabilities
..Default::default()
})));
server.respond(response)?;
}
Command::Launch(_) => {
// Handle launch request
let response = req.success(ResponseBody::Launch);
server.respond(response)?;
}
Command::Threads => {
// Handle threads request
let response = req.success(ResponseBody::Threads(ThreadsResponseBody {
threads: vec![],
}));
server.respond(response)?;
}
_ => {
// Handle other commands
}
}
}
}
Key Improvements Over Original
1. Cross-Platform Compatibility
The original dap-rs had issues with clients like Zed and IntelliJ IDEA that send empty arguments: {} objects for commands that don't require arguments, while VS Code omits the field entirely.
This fork implements a custom deserializer that accepts both formats:
// VS Code style (no arguments field)
{"command": "threads", "seq": 1, "type": "request"}
// Zed/IntelliJ style (empty arguments object)
{"command": "threads", "seq": 1, "type": "request", "arguments": {}}
Both formats deserialize correctly to the same Command::Threads variant.
2. Unconditional Serialization Traits
Removed conditional compilation attributes (#[cfg_attr(feature = "client", ...)]) to ensure Serialize and Deserialize are always available, improving ergonomics and compatibility.
3. Optimized I/O Operations
The Server implementation has been optimized to reduce the number of write operations, improving performance for high-frequency request/response scenarios.
Architecture
The crate is organized into several modules:
requests- Request types and theCommandenumresponses- Response types and bodiesevents- Event types sent by the debug adaptertypes- Common types used across requests, responses, and eventsserver- I/O utilities for implementing a debug adaptererrors- Error types
DAP Specification Compliance
This implementation follows the Debug Adapter Protocol Specification. All protocol types are documented with links to the corresponding specification sections.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Credits
This project is a fork of dap-rs by @sztomi. Special thanks to the original author for the foundational work.
License
This project is licensed under the MIT License - see the LICENSE file for details.
See Also
Dependencies
~0.5–1.4MB
~29K SLoC