pub struct Partition { /* private fields */ }Expand description
A single partition backed by a memory lease.
Implementations§
Source§impl Partition
impl Partition
Sourcepub fn new(capacity: usize, stride: usize) -> Result<Self>
pub fn new(capacity: usize, stride: usize) -> Result<Self>
Create a new partition with the given capacity and slot stride.
Acquires a memory lease large enough for the header plus all slots.
Sourcepub fn append(&mut self, key: Option<&[u8]>, value: &[u8]) -> Result<u64>
pub fn append(&mut self, key: Option<&[u8]>, value: &[u8]) -> Result<u64>
Append a message to the partition.
The message’s offset and timestamp fields are set automatically.
Returns the assigned offset, or CapacityExceeded if the serialized
message exceeds the slot stride.
Sourcepub fn read_at(&self, offset: u64) -> Result<Option<Message>>
pub fn read_at(&self, offset: u64) -> Result<Option<Message>>
Read the message at the given absolute offset.
Returns None if the offset has been overwritten (wrapped) or is
beyond the current write position.
Sourcepub fn next_offset(&self) -> u64
pub fn next_offset(&self) -> u64
Returns the next offset that will be assigned.
Sourcepub fn oldest_offset(&self) -> u64
pub fn oldest_offset(&self) -> u64
Returns the oldest available offset (messages before this have been overwritten).
Auto Trait Implementations§
impl Freeze for Partition
impl !RefUnwindSafe for Partition
impl !Send for Partition
impl !Sync for Partition
impl Unpin for Partition
impl !UnwindSafe for Partition
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