Skip to content

Commit

Permalink
PosixHeader: derive PartialEq and Eq
Browse files Browse the repository at this point in the history
  • Loading branch information
phip1611 committed May 3, 2024
1 parent ec7b191 commit 1298658
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum ModeError {
}

/// Wrapper around the UNIX file permissions given in octal ASCII.
#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialEq, Eq)]
#[repr(transparent)]
pub struct Mode(TarFormatOctal<8>);

Expand Down Expand Up @@ -72,8 +72,7 @@ impl Debug for Mode {
/// This is also mostly compatible with the "Ustar"-header and the "GNU format".
/// Because this library only needs to fetch data and filename, we don't need
/// further checks.
// TODO make PartialEq?
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(C, packed)]
pub struct PosixHeader {
pub name: TarFormatString<NAME_LEN>,
Expand Down
8 changes: 4 additions & 4 deletions src/tar_format_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use num_traits::Num;
///
/// The content is likely to be UTF-8/ASCII, but that is not verified by this
/// type. The
#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialEq, Eq)]
#[repr(C)]
pub struct TarFormatString<const N: usize> {
bytes: [u8; N],
Expand Down Expand Up @@ -83,17 +83,17 @@ impl<const N: usize> Debug for TarFormatString<N> {
}

/// A number with a specified base. Trailing spaces in the string are ignored.
#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialEq, Eq)]
#[repr(C)]
pub struct TarFormatNumber<const N: usize, const R: u32>(TarFormatString<N>);

/// An octal number. Trailing spaces in the string are ignored.
#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialEq, Eq)]
#[repr(C)]
pub struct TarFormatOctal<const N: usize>(TarFormatNumber<N, 8>);

/// A decimal number. Trailing spaces in the string are ignored.
#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialEq, Eq)]
#[repr(C)]
pub struct TarFormatDecimal<const N: usize>(TarFormatNumber<N, 10>);

Expand Down

0 comments on commit 1298658

Please sign in to comment.