pub struct Message {
pub id: Uuid,
pub body: String,
pub state: MessageState,
pub lock_until: Option<String>,
pub retry_count: u32,
}Expand description
Represents a message in the TLQ queue system.
Each message has a unique identifier, content, and metadata about its processing state. Messages are automatically assigned UUID v7 identifiers which provide time-ordering.
§Examples
use tlq_client::Message;
// Create a new message
let message = Message::new("Hello, World!".to_string());
println!("Message ID: {}", message.id);
println!("Message body: {}", message.body);Fields§
§id: UuidUnique identifier for the message (UUID v7 format for time-ordering)
body: StringThe message content/body as a string
state: MessageStateCurrent processing state of the message
lock_until: Option<String>Optional ISO datetime string indicating when the message lock expires
retry_count: u32Number of times this message has been retried after failure
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(body: String) -> Self
pub fn new(body: String) -> Self
Creates a new message with the specified body content.
The message is initialized with:
- A new UUID v7 identifier (provides time-ordering)
- State set to
MessageState::Ready - No lock expiration time
- Zero retry count
§Arguments
body- The message content as a String
§Examples
use tlq_client::{Message, MessageState};
let message = Message::new("Process this task".to_string());
assert_eq!(message.body, "Process this task");
assert_eq!(message.state, MessageState::Ready);
assert_eq!(message.retry_count, 0);
assert!(message.lock_until.is_none());Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more