pub struct Record { /* private fields */ }Expand description
Implementations§
Source§impl Record
impl Record
Sourcepub fn lsn(&self) -> Lsn
pub fn lsn(&self) -> Lsn
The sequence number this record was assigned — its byte offset in the log.
Sourcepub fn into_data(self) -> Vec<u8> ⓘ
pub fn into_data(self) -> Vec<u8> ⓘ
Consume the record and take ownership of its payload without copying.
Sourcepub fn decode<T: Deserialize>(&self) -> Result<T>
pub fn decode<T: Deserialize>(&self) -> Result<T>
Decode the record’s payload into a typed value via pack-io.
The mirror of Wal::append_typed. Available with the pack-io feature.
§Errors
Returns WalError::Encoding if the bytes do not deserialise into T —
for example reading a record written as a different type.
§Examples
use wal_db::{MemStore, Wal};
use wal_db::pack_io::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, PartialEq, Debug)]
struct Event {
id: u64,
name: String,
}
let wal = Wal::with_store(MemStore::new())?;
wal.append_typed(&Event { id: 7, name: "boot".into() })?;
let record = wal.iter()?.next().unwrap()?;
let event: Event = record.decode()?;
assert_eq!(event, Event { id: 7, name: "boot".into() });Trait Implementations§
impl Eq for Record
impl StructuralPartialEq for Record
Auto Trait Implementations§
impl Freeze for Record
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnsafeUnpin for Record
impl UnwindSafe for Record
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