Skip to main content

MessageOptions

Struct MessageOptions 

Source
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: bool

Enable message signing (HMAC)

§signing_key: Option<Vec<u8>>

Signing key for HMAC (if signing is enabled)

§encrypt: bool

Enable message encryption (AES-256-GCM)

§encryption_key: Option<Vec<u8>>

Encryption key (32 bytes for AES-256)

§compress: bool

Compression hint

Implementations§

Source§

impl MessageOptions

Source

pub fn new() -> Self

Create new message options

Source

pub fn with_priority(self, priority: Priority) -> Self

Set priority

Source

pub fn with_ttl(self, ttl: Duration) -> Self

Set TTL

Source

pub fn with_expires_at(self, timestamp: u64) -> Self

Set expiration timestamp (Unix timestamp in seconds)

Source

pub fn with_delay(self, delay: Duration) -> Self

Set delay

Source

pub fn with_correlation_id(self, id: impl Into<String>) -> Self

Set correlation ID

Source

pub fn with_reply_to(self, queue: impl Into<String>) -> Self

Set reply-to queue

Source

pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Add a custom header

Source

pub fn with_signing(self, key: Vec<u8>) -> Self

Enable message signing with HMAC

Source

pub fn with_encryption(self, key: Vec<u8>) -> Self

Enable message encryption with AES-256-GCM

Source

pub fn with_compression(self) -> Self

Enable compression

Source

pub fn is_expired(&self, current_timestamp: u64) -> bool

Check if message has expired (based on expires_at)

Source

pub fn should_delay(&self) -> bool

Check if message should be delayed

Source

pub fn should_sign(&self) -> bool

Check if message should be signed

Source

pub fn should_encrypt(&self) -> bool

Check if message should be encrypted

Source

pub fn should_compress(&self) -> bool

Check if message should be compressed

Trait Implementations§

Source§

impl Clone for MessageOptions

Source§

fn clone(&self) -> MessageOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MessageOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MessageOptions

Source§

fn default() -> MessageOptions

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MessageOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for MessageOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,