Expand description
Lazy deserialization for improved performance
This module provides lazy deserialization capabilities where message bodies and other large data structures are only deserialized when actually accessed. This is particularly useful for:
- Large message bodies that may not always be needed
- Message routing/filtering scenarios where only headers are needed
- High-throughput scenarios where deserialization overhead matters
§Examples
use celers_protocol::lazy::LazyMessage;
use uuid::Uuid;
let task_id = Uuid::new_v4();
let json = format!(r#"{{"headers":{{"task":"tasks.add","id":"{}","lang":"rust"}},"properties":{{"delivery_mode":2}},"body":"e30=","content-type":"application/json","content-encoding":"utf-8"}}"#, task_id);
// Parse only the headers initially
let msg = LazyMessage::from_json(json.as_bytes()).unwrap();
// Headers are immediately available
assert_eq!(msg.task_name(), "tasks.add");
// Body is only deserialized when accessed
let body = msg.body().unwrap();Structs§
- Lazy
Body - Lazy-deserialized message body
- Lazy
Message - Lazy-deserialized message
- Lazy
Task Args - Lazy task arguments
Enums§
- Lazy
Error - Error type for lazy deserialization