Module protocol

Module protocol 

Source
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

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§

Protocol
Protocol handler for Claude Code JSON lines communication

Enums§

MessageEnvelope
Message envelope for routing different message types