add serde support to Lsn type

A serialized Lsn and a serialized u64 should be identical.
This commit is contained in:
Eric Seppanen
2021-05-07 15:41:29 -07:00
parent 294320e6a8
commit 60d66267a9
2 changed files with 4 additions and 3 deletions

View File

@@ -5,11 +5,10 @@ authors = ["Eric Seppanen <eric@zenith.tech>"]
edition = "2018"
[dependencies]
serde = "1.0"
serde = { version = "1.0", features = ["derive"] }
bincode = "1.3"
thiserror = "1.0"
[dev-dependencies]
serde = { version = "1.0", features = ["derive"] }
hex-literal = "0.3"
bytes = "1.0"

View File

@@ -1,5 +1,6 @@
#![warn(missing_docs)]
use serde::{Deserialize, Serialize};
use std::fmt;
use std::ops::{Add, AddAssign};
use std::path::Path;
@@ -10,7 +11,8 @@ use std::sync::atomic::{AtomicU64, Ordering};
pub const XLOG_BLCKSZ: u32 = 8192;
/// A Postgres LSN (Log Sequence Number), also known as an XLogRecPtr
#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd, Serialize, Deserialize)]
#[serde(transparent)]
pub struct Lsn(pub u64);
/// We tried to parse an LSN from a string, but failed