pub struct MessageOptions {
pub priority: Option<Priority>,
pub ttl: Option<Duration>,
pub expires_at: Option<u64>,
pub delay: Option<Duration>,
pub correlation_id: Option<String>,
pub reply_to: Option<String>,
pub headers: HashMap<String, String>,
pub sign: bool,
pub signing_key: Option<Vec<u8>>,
pub encrypt: bool,
pub encryption_key: Option<Vec<u8>>,
pub compress: bool,
}Expand description
Message-level options
§Examples
use celers_kombu::{MessageOptions, Priority};
use std::time::Duration;
let options = MessageOptions::new()
.with_priority(Priority::High)
.with_ttl(Duration::from_secs(3600))
.with_correlation_id("req-123".to_string())
.with_reply_to("response_queue".to_string());
assert_eq!(options.priority, Some(Priority::High));
assert_eq!(options.ttl, Some(Duration::from_secs(3600)));
assert_eq!(options.correlation_id, Some("req-123".to_string()));
// Check if message should be signed
let secure_options = MessageOptions::new()
.with_signing(b"secret-key".to_vec());
assert!(secure_options.should_sign());Fields§
§priority: Option<Priority>Message priority
ttl: Option<Duration>Message TTL (time-to-live)
expires_at: Option<u64>Message expiration timestamp (absolute)
delay: Option<Duration>Delay before message becomes visible
correlation_id: Option<String>Correlation ID for request/response patterns
reply_to: Option<String>Reply-to queue for RPC patterns
headers: HashMap<String, String>Custom headers
sign: boolEnable message signing (HMAC)
signing_key: Option<Vec<u8>>Signing key for HMAC (if signing is enabled)
encrypt: boolEnable message encryption (AES-256-GCM)
encryption_key: Option<Vec<u8>>Encryption key (32 bytes for AES-256)
compress: boolCompression hint
Implementations§
Source§impl MessageOptions
impl MessageOptions
Sourcepub fn with_priority(self, priority: Priority) -> Self
pub fn with_priority(self, priority: Priority) -> Self
Set priority
Sourcepub fn with_expires_at(self, timestamp: u64) -> Self
pub fn with_expires_at(self, timestamp: u64) -> Self
Set expiration timestamp (Unix timestamp in seconds)
Sourcepub fn with_delay(self, delay: Duration) -> Self
pub fn with_delay(self, delay: Duration) -> Self
Set delay
Sourcepub fn with_correlation_id(self, id: impl Into<String>) -> Self
pub fn with_correlation_id(self, id: impl Into<String>) -> Self
Set correlation ID
Sourcepub fn with_reply_to(self, queue: impl Into<String>) -> Self
pub fn with_reply_to(self, queue: impl Into<String>) -> Self
Set reply-to queue
Sourcepub fn with_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a custom header
Sourcepub fn with_signing(self, key: Vec<u8>) -> Self
pub fn with_signing(self, key: Vec<u8>) -> Self
Enable message signing with HMAC
Sourcepub fn with_encryption(self, key: Vec<u8>) -> Self
pub fn with_encryption(self, key: Vec<u8>) -> Self
Enable message encryption with AES-256-GCM
Sourcepub fn with_compression(self) -> Self
pub fn with_compression(self) -> Self
Enable compression
Sourcepub fn is_expired(&self, current_timestamp: u64) -> bool
pub fn is_expired(&self, current_timestamp: u64) -> bool
Check if message has expired (based on expires_at)
Sourcepub fn should_delay(&self) -> bool
pub fn should_delay(&self) -> bool
Check if message should be delayed
Sourcepub fn should_sign(&self) -> bool
pub fn should_sign(&self) -> bool
Check if message should be signed
Sourcepub fn should_encrypt(&self) -> bool
pub fn should_encrypt(&self) -> bool
Check if message should be encrypted
Sourcepub fn should_compress(&self) -> bool
pub fn should_compress(&self) -> bool
Check if message should be compressed
Trait Implementations§
Source§impl Clone for MessageOptions
impl Clone for MessageOptions
Source§fn clone(&self) -> MessageOptions
fn clone(&self) -> MessageOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more