Expand description
Core message types and serialization logic. Optimized message types and serialization.
This module provides the standard message handling abstraction for TurboMCP.
It supports multiple serialization formats (JSON, MessagePack, CBOR) and
includes SIMD acceleration when available.
§Message Types
This is the recommended message type for most use cases. It provides:
- Multiple serialization formats (JSON,MessagePack,CBOR)
- Automatic format detection
- SIMD-accelerated JSON parsing (when simdfeature enabled)
- Cached parsed values for efficient reuse
- Ergonomic API for common operations
For extreme performance scenarios, see ZeroCopyMessage.
§Example
use turbomcp_protocol::{Message, MessageId};
use serde_json::json;
// Create a JSON message
let msg = Message::json(
    MessageId::from("req-1"),
    json!({"method": "test", "params": {}})
)?;
// Parse to specific type
#[derive(serde::Deserialize)]
struct Request {
    method: String,
    params: serde_json::Value,
}
let request: Request = msg.parse_json()?;
assert_eq!(request.method, "test");Structs§
- BinaryPayload 
- Binary payload for efficient serialization formats
- JsonPayload 
- JSON payload with zero-copy support
- Message
- Optimized message container with zero-copy support
- MessageMetadata 
- Message metadata for tracking and debugging
- MessageSerializer 
- Message serializer with format detection
Enums§
- BinaryFormat 
- Supported binary serialization formats
- MessageId 
- Unique identifier for messages
- MessagePayload 
- Zero-copy message payload
- SerializationFormat 
- Supported serialization formats