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§
- Binary
Payload - Binary payload for efficient serialization formats
- Json
Payload - JSON payload with zero-copy support
- Message
- Optimized message container with zero-copy support
- Message
Metadata - Message metadata for tracking and debugging
- Message
Serializer - Message serializer with format detection
Enums§
- Binary
Format - Supported binary serialization formats
- Message
Id - Unique identifier for messages
- Message
Payload - Zero-copy message payload
- Serialization
Format - Supported serialization formats