Skip to content

Commit 07dc9b5

Browse files
committed
add LibsqlWalFooter
1 parent a4af6c6 commit 07dc9b5

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

libsql-wal/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ const LIBSQL_MAGIC: u64 = u64::from_be_bytes(*b"LIBSQL\0\0");
1515
const LIBSQL_PAGE_SIZE: u16 = 4096;
1616
const LIBSQL_WAL_VERSION: u16 = 1;
1717

18+
use zerocopy::byteorder::big_endian::{U64 as bu64, U16 as bu16};
19+
/// LibsqlFooter is located at the end of the libsql file. I contains libsql specific metadata,
20+
/// while remaining fully compatible with sqlite (which just ignores that footer)
21+
///
22+
/// The fields are in big endian to remain coherent with sqlite
23+
#[derive(Copy, Clone, Debug, zerocopy::FromBytes, zerocopy::FromZeroes, zerocopy::AsBytes)]
24+
#[repr(C)]
25+
pub struct LibsqlFooter {
26+
magic: bu64,
27+
version: bu16,
28+
/// Replication index checkpointed into this file.
29+
/// only valid if there are no outstanding segments to checkpoint, since a checkpoint could be
30+
/// partial.
31+
replication_index: bu64,
32+
}
33+
1834
#[cfg(any(debug_assertions, test))]
1935
pub mod test {
2036
use std::fs::OpenOptions;

0 commit comments

Comments
 (0)