pub struct MessageRef<'a> {
pub headers: MessageHeadersRef<'a>,
pub properties: MessagePropertiesRef<'a>,
pub body: Cow<'a, [u8]>,
pub content_type: Cow<'a, str>,
pub content_encoding: Cow<'a, str>,
}Expand description
Zero-copy Celery message
Uses borrowed data where possible to avoid unnecessary allocations. This is particularly useful when deserializing messages from a buffer that will remain valid for the lifetime of the message.
Fields§
§headers: MessageHeadersRef<'a>Message headers (zero-copy)
properties: MessagePropertiesRef<'a>Message properties (zero-copy)
body: Cow<'a, [u8]>Message body (zero-copy reference to raw bytes)
content_type: Cow<'a, str>Content type (zero-copy)
content_encoding: Cow<'a, str>Content encoding (zero-copy)
Implementations§
Source§impl<'a> MessageRef<'a>
impl<'a> MessageRef<'a>
Sourcepub fn new(task: &'a str, id: Uuid, body: &'a [u8]) -> Self
pub fn new(task: &'a str, id: Uuid, body: &'a [u8]) -> Self
Create a new zero-copy message reference
Sourcepub fn body_slice(&self) -> &[u8] ⓘ
pub fn body_slice(&self) -> &[u8] ⓘ
Get body as slice
Sourcepub fn has_expires(&self) -> bool
pub fn has_expires(&self) -> bool
Check if message has expiration
Sourcepub fn has_parent(&self) -> bool
pub fn has_parent(&self) -> bool
Check if message has parent
Sourcepub fn into_owned(self) -> Message
pub fn into_owned(self) -> Message
Convert to owned message
Trait Implementations§
Source§impl<'a> Clone for MessageRef<'a>
impl<'a> Clone for MessageRef<'a>
Source§fn clone(&self) -> MessageRef<'a>
fn clone(&self) -> MessageRef<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for MessageRef<'a>
impl<'a> Debug for MessageRef<'a>
Source§impl<'de: 'a, 'a> Deserialize<'de> for MessageRef<'a>
impl<'de: 'a, 'a> Deserialize<'de> for MessageRef<'a>
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
Auto Trait Implementations§
impl<'a> Freeze for MessageRef<'a>
impl<'a> RefUnwindSafe for MessageRef<'a>
impl<'a> Send for MessageRef<'a>
impl<'a> Sync for MessageRef<'a>
impl<'a> Unpin for MessageRef<'a>
impl<'a> UnwindSafe for MessageRef<'a>
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