| 1 | //! Log Sequence Number (LSN) type for PostgreSQL Write-Ahead Log |
| 2 | //! (WAL), also known as the transaction log. |
| 3 | |
| 4 | use bytesrust-analyzer cargo bytes 1.11.1 crate/::BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#; |
| 5 | use postgres_protocolrust-analyzer cargo postgres-protocol 0.6.12 crate/::typesrust-analyzer cargo postgres-protocol 0.6.12 types/; |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#; |
| 7 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#; |
| 9 | |
| 10 | use craterust-analyzer cargo postgres-types 0.2.14 crate/::{FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#, IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#, ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#, Typerust-analyzer cargo postgres-types 0.2.14 Type#}; |
| 11 | |
| 12 | /// Postgres `PG_LSN` type. |
| 13 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)] |
| 14 | pub struct PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn#(u64); |
| 15 | |
| 16 | /// Error parsing LSN. |
| 17 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 18 | pub struct ParseLsnErrorrust-analyzer cargo postgres-types 0.2.14 pg_lsn/ParseLsnError#(()); |
| 19 | |
| 20 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<u64> for PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn# { |
| 21 | fn fromrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][`From<u64>`]from().(lsn_u64: u64) -> Selfrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][`From<u64>`] { |
| 22 | PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn#(lsn_u64) |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn#> for u64 { |
| 27 | fn fromrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[u64][`From<PgLsn>`]from().(lsn: PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn#) -> u64 { |
| 28 | lsn.0rust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn#0. |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn# { |
| 33 | type Errrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][FromStr]Err# = ParseLsnErrorrust-analyzer cargo postgres-types 0.2.14 pg_lsn/ParseLsnError#; |
| 34 | |
| 35 | fn from_strrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][FromStr]from_str().(lsn_str: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][FromStr], Selfrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 36 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((split_hi, split_lo)) = lsn_str.split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().('/') else { |
| 37 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ParseLsnErrorrust-analyzer cargo postgres-types 0.2.14 pg_lsn/ParseLsnError#(())); |
| 38 | }; |
| 39 | let (hi, lo) = ( |
| 40 | u64::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]from_str_radix().(split_hi, 16).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| ParseLsnErrorrust-analyzer cargo postgres-types 0.2.14 pg_lsn/ParseLsnError#(()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 41 | u64::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]from_str_radix().(split_lo, 16).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| ParseLsnErrorrust-analyzer cargo postgres-types 0.2.14 pg_lsn/ParseLsnError#(()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 42 | ); |
| 43 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn#((hi rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<i32>`]shl().32) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOr<Self>`]bitor().lo)) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn# { |
| 48 | fn fmtrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 49 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{:X}/{:X}", self.0rust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn#0. >> 32, self.0rust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn#0. &rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand(). 0x00000000ffffffff) |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn# { |
| 54 | fn fmtrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 55 | fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#::fmtrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][Display]fmt().(self, f) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn# { |
| 60 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][`FromSql<'a>`]from_sql().(_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][`FromSql<'a>`], Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#>> { |
| 61 | let v = typesrust-analyzer cargo postgres-protocol 0.6.12 types/::lsn_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/lsn_from_sql().(raw)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 62 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 63 | } |
| 64 | |
| 65 | acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(PG_LSNrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]PG_LSN.); |
| 66 | } |
| 67 | |
| 68 | impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn# { |
| 69 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 pg_lsn/impl#[PgLsn][ToSql]to_sql().(&self, _: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, out: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#>> { |
| 70 | typesrust-analyzer cargo postgres-protocol 0.6.12 types/::lsn_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/lsn_to_sql().((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), out); |
| 71 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Norust-analyzer cargo postgres-types 0.2.14 IsNull#No#) |
| 72 | } |
| 73 | |
| 74 | acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(PG_LSNrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]PG_LSN.); |
| 75 | |
| 76 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 77 | } |