Skip to content

Commit

Permalink
add LibsqlWalFooter
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Aug 7, 2024
1 parent a4af6c6 commit 07dc9b5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libsql-wal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ const LIBSQL_MAGIC: u64 = u64::from_be_bytes(*b"LIBSQL\0\0");
const LIBSQL_PAGE_SIZE: u16 = 4096;
const LIBSQL_WAL_VERSION: u16 = 1;

use zerocopy::byteorder::big_endian::{U64 as bu64, U16 as bu16};
/// LibsqlFooter is located at the end of the libsql file. I contains libsql specific metadata,
/// while remaining fully compatible with sqlite (which just ignores that footer)
///
/// The fields are in big endian to remain coherent with sqlite
#[derive(Copy, Clone, Debug, zerocopy::FromBytes, zerocopy::FromZeroes, zerocopy::AsBytes)]
#[repr(C)]
pub struct LibsqlFooter {
magic: bu64,
version: bu16,
/// Replication index checkpointed into this file.
/// only valid if there are no outstanding segments to checkpoint, since a checkpoint could be
/// partial.
replication_index: bu64,
}

#[cfg(any(debug_assertions, test))]
pub mod test {
use std::fs::OpenOptions;
Expand Down

0 comments on commit 07dc9b5

Please sign in to comment.