pub struct ZeroCopyMessage {
pub id: Arc<MessageId>,
pub payload: Bytes,
pub lazy_json: Option<Box<RawValue>>,
pub metadata: MessageMetadata,
}
Expand description
Zero-copy message with lazy deserialization
Fields§
§id: Arc<MessageId>
Message ID - using Arc for cheap cloning
payload: Bytes
Raw message payload - zero-copy bytes
lazy_json: Option<Box<RawValue>>
Lazy-parsed JSON value for deferred deserialization
metadata: MessageMetadata
Message metadata
Implementations§
Source§impl ZeroCopyMessage
impl ZeroCopyMessage
Sourcepub fn from_bytes(id: MessageId, payload: Bytes) -> Self
pub fn from_bytes(id: MessageId, payload: Bytes) -> Self
Create a new zero-copy message from bytes
Sourcepub fn from_json<T: Serialize>(id: MessageId, value: &T) -> Result<Self>
pub fn from_json<T: Serialize>(id: MessageId, value: &T) -> Result<Self>
Create from a JSON value with zero-copy optimization
Sourcepub fn parse_json_lazy(&mut self) -> Result<&RawValue>
pub fn parse_json_lazy(&mut self) -> Result<&RawValue>
Parse JSON lazily - only when needed
Sourcepub fn deserialize<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
pub fn deserialize<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
Deserialize a specific type from the message with SIMD acceleration when available
Sourcepub fn payload_slice(&self) -> &[u8] ⓘ
pub fn payload_slice(&self) -> &[u8] ⓘ
Get a zero-copy view of the payload
Sourcepub fn cheap_clone(&self) -> Self
pub fn cheap_clone(&self) -> Self
Clone the message cheaply (Arc increments only)
Trait Implementations§
Source§impl Clone for ZeroCopyMessage
impl Clone for ZeroCopyMessage
Source§fn clone(&self) -> ZeroCopyMessage
fn clone(&self) -> ZeroCopyMessage
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 moreAuto Trait Implementations§
impl !Freeze for ZeroCopyMessage
impl RefUnwindSafe for ZeroCopyMessage
impl Send for ZeroCopyMessage
impl Sync for ZeroCopyMessage
impl Unpin for ZeroCopyMessage
impl UnwindSafe for ZeroCopyMessage
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