Module lazy

Module lazy 

Source
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§

LazyBody
Lazy-deserialized message body
LazyMessage
Lazy-deserialized message
LazyTaskArgs
Lazy task arguments

Enums§

LazyError
Error type for lazy deserialization