pub struct MmapMessage {
pub id: Arc<MessageId>,
pub data: Bytes,
pub metadata: MessageMetadata,
}Available on non-crate feature
mmap only.Expand description
Fallback implementation using regular file I/O
Fields§
§id: Arc<MessageId>Unique message identifier
data: BytesMessage data as bytes
metadata: MessageMetadataMessage metadata
Implementations§
Source§impl MmapMessage
impl MmapMessage
Sourcepub fn from_file(
id: MessageId,
path: &Path,
offset: usize,
length: Option<usize>,
) -> Result<Self>
pub fn from_file( id: MessageId, path: &Path, offset: usize, length: Option<usize>, ) -> Result<Self>
Create a message by reading from a file
Sourcepub fn parse_json<T>(&self) -> Result<T>where
T: for<'de> Deserialize<'de>,
pub fn parse_json<T>(&self) -> Result<T>where
T: for<'de> Deserialize<'de>,
Parse the message data as JSON
Sourcepub async fn from_file_async(
id: MessageId,
path: &Path,
offset: usize,
length: Option<usize>,
) -> Result<Self>
pub async fn from_file_async( id: MessageId, path: &Path, offset: usize, length: Option<usize>, ) -> Result<Self>
Create a message from a file (ASYNC - Non-blocking fallback!)
This is the async version of from_file for the non-mmap fallback
that uses tokio::task::spawn_blocking to avoid blocking the async runtime.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MmapMessage
impl RefUnwindSafe for MmapMessage
impl Send for MmapMessage
impl Sync for MmapMessage
impl Unpin for MmapMessage
impl UnwindSafe for MmapMessage
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