Skip to content

Commit

Permalink
Refactor magic number to more compact format.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoquick committed Sep 1, 2023
1 parent e34b738 commit 69cdeb4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:#?}")));
}

Expand Down

0 comments on commit 69cdeb4

Please sign in to comment.