pub struct MsgPackCodec;msgpack only.Expand description
MessagePack binary codec
This codec produces compact binary output, suitable for high-throughput scenarios where bandwidth is limited.
Note: MessagePack is not MCP-compliant for external communication but can be used for internal message passing.
§Security Considerations
When using MessagePack for untrusted input, be aware of:
§Nesting Depth
Deeply nested structures can cause stack overflow. The underlying rmp-serde
library has default recursion limits, but extremely nested payloads may still
cause issues. Consider validating message structure before decoding.
§Binary Field Size
MessagePack can encode arbitrarily large binary/string fields. Applications should:
- Enforce maximum message size limits at the transport layer
- Use streaming decoders for large payloads when possible
- Set appropriate memory limits in production environments
§Type Confusion
MessagePack’s dynamic typing can lead to type confusion attacks. Always:
- Validate deserialized data matches expected schema
- Use strongly-typed Rust structs rather than
serde_json::Value - Check for unexpected field types after deserialization
§Recommended Usage
For production systems handling untrusted input, prefer JSON (with schema validation) or use MessagePack only within trusted boundaries (internal microservices, etc.).
Implementations§
Source§impl MsgPackCodec
impl MsgPackCodec
Trait Implementations§
Source§impl Clone for MsgPackCodec
impl Clone for MsgPackCodec
Source§fn clone(&self) -> MsgPackCodec
fn clone(&self) -> MsgPackCodec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more