pub struct Encoder<'a, W>where
W: Write,{ /* private fields */ }Expand description
An LTX file encoder.
§Example
let mut enc = litetx::Encoder::new(&mut w, &litetx::Header{
flags: litetx::HeaderFlags::empty(),
page_size: litetx::PageSize::new(4096).unwrap(),
commit: litetx::PageNum::new(1).unwrap(),
min_txid: litetx::TXID::ONE,
max_txid: litetx::TXID::ONE,
timestamp: SystemTime::now(),
pre_apply_checksum: None,
}).expect("encoder");
let page_num = litetx::PageNum::new(1).unwrap();
enc.encode_page(page_num, &page).expect("encode_page");
enc.finish(page.page_checksum(page_num)).expect("finish");Implementations§
Source§impl<'a, W> Encoder<'a, W>where
W: Write,
impl<'a, W> Encoder<'a, W>where
W: Write,
Sourcepub fn encode_page(
&mut self,
page_num: PageNum,
data: &[u8],
) -> Result<(), Error>
pub fn encode_page( &mut self, page_num: PageNum, data: &[u8], ) -> Result<(), Error>
Encode a page with the given page_num and data.
Depending on the Header passed to Encoder::new, the following constraints
are applied:
- if
min_txidis 1, the LTX file is considered to be a full snapshot of the database and must contain all pages from the first one up tocommitin increasing oreder. - if
min_txidis greater than 1, the LTX file may contain a subset of database pages in increasing order.
Auto Trait Implementations§
impl<'a, W> Freeze for Encoder<'a, W>where
W: Freeze,
impl<'a, W> RefUnwindSafe for Encoder<'a, W>where
W: RefUnwindSafe,
impl<'a, W> Send for Encoder<'a, W>where
W: Send,
impl<'a, W> Sync for Encoder<'a, W>where
W: Sync,
impl<'a, W> Unpin for Encoder<'a, W>where
W: Unpin,
impl<'a, W> UnsafeUnpin for Encoder<'a, W>where
W: UnsafeUnpin,
impl<'a, W> UnwindSafe for Encoder<'a, W>where
W: UnwindSafe,
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