From 69cdeb4417604781376f6ad87b149265c2a602a3 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Fri, 1 Sep 2023 15:31:55 -0600 Subject: [PATCH 1/2] Refactor magic number to more compact format. --- src/constants.rs | 4 +--- src/file.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index 2731c33..aec9024 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -2,9 +2,7 @@ use bitmask_enum::bitmask; use serde::{Deserialize, Serialize}; /// "Magic number" used by the Carbonado file format. 12 bytes: "CARBONADO", and a version, 00, plus a newline character -pub const MAGICNO: [u8; 12] = [ - b'C', b'A', b'R', b'B', b'O', b'N', b'A', b'D', b'O', b'0', b'0', b'\n', -]; +pub const MAGICNO: &[u8; 12] = b"CARBONADO00\n"; /// Bao slice length pub const SLICE_LEN: u16 = 1024; diff --git a/src/file.rs b/src/file.rs index d59aca0..1a90622 100644 --- a/src/file.rs +++ b/src/file.rs @@ -70,7 +70,7 @@ impl TryFrom<&File> for Header { handle.read_exact(&mut padding_len)?; handle.read_exact(&mut metadata)?; - if magic_no != MAGICNO { + if &magic_no != MAGICNO { return Err(CarbonadoError::InvalidMagicNumber(format!("{magic_no:#?}"))); } From 518188593fc2a86bf2fa687f9165b83904c0d64f Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Fri, 1 Sep 2023 15:44:37 -0600 Subject: [PATCH 2/2] Pin once_cell to 1.17.0 due to sync::Lazy not found error. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ae254f6..0a90249 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,8 @@ secp256k1 = { version = "0.27.0", features = [ serde = "1.0.164" snap = "1.1.0" thiserror = "1.0" - zfec-rs = "0.1.0" +once_cell = "=1.17.0" [dev-dependencies] anyhow = "1.0.71"