A Rust implementation of the Debug Adapter Protocol (DAP) types and utilities.
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.
- ✅ 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
Add this to your Cargo.toml:
[dependencies]
emmy_dap_types = "0.1"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
}
}
}
}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.
Removed conditional compilation attributes (#[cfg_attr(feature = "client", ...)]) to ensure Serialize and Deserialize are always available, improving ergonomics and compatibility.
The Server implementation has been optimized to reduce the number of write operations, improving performance for high-frequency request/response scenarios.
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
This implementation follows the Debug Adapter Protocol Specification. All protocol types are documented with links to the corresponding specification sections.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is a fork of dap-rs by @sztomi. Special thanks to the original author for the foundational work.
This project is licensed under the MIT License - see the LICENSE file for details.