Expand description
JSON Lines protocol implementation for Claude communication.
This module provides the Protocol struct with methods for:
- Serializing messages to JSON Lines format
- Deserializing JSON Lines into typed messages
- Reading/writing messages over sync and async I/O
The JSON Lines format means each message is a complete JSON object on a single line, terminated by a newline character. This enables streaming communication where messages can be processed as they arrive.
§Example
use claude_codes::{Protocol, ClaudeInput};
// Serialize a message
let input = ClaudeInput::user_message("Hello!", uuid::Uuid::new_v4());
let json_line = Protocol::serialize(&input)?;
assert!(json_line.ends_with('\n'));
// Deserialize a message
let output = Protocol::deserialize::<serde_json::Value>(&json_line)?;Structs§
- Async
Stream Processor - Async stream processor for handling continuous message streams
- Protocol
- Protocol handler for Claude Code JSON lines communication
- Stream
Processor - Stream processor for handling continuous message streams
Enums§
- Message
Envelope - Message envelope for routing different message types