Skip to content

Commit

Permalink
Merge pull request #101 from Jake-Shadle/master
Browse files Browse the repository at this point in the history
Remove `num_enum`
  • Loading branch information
Pr0methean authored May 9, 2024
2 parents c39f5e8 + ed35b9f commit 769fff2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ displaydoc = { version = "0.2.4", default-features = false }
flate2 = { version = "1.0.28", default-features = false, optional = true }
indexmap = "2"
hmac = { version = "0.12.1", optional = true, features = ["reset"] }
num_enum = "0.7.2"
pbkdf2 = { version = "0.12.2", optional = true }
rand = { version = "0.8.5", optional = true }
sha1 = { version = "0.10.6", optional = true }
Expand Down
24 changes: 21 additions & 3 deletions src/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Types that specify what is contained in a ZIP.
use num_enum::{FromPrimitive, IntoPrimitive};
use path::{Component, Path, PathBuf};
use std::path;
use std::sync::{Arc, OnceLock};
Expand All @@ -21,15 +20,34 @@ use crate::CompressionMethod;
#[cfg(feature = "time")]
use time::{error::ComponentRange, Date, Month, OffsetDateTime, PrimitiveDateTime, Time};

#[derive(Clone, Copy, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum System {
Dos = 0,
Unix = 3,
#[num_enum(default)]
Unknown,
}

impl From<u8> for System {
fn from(system: u8) -> Self {
match system {
0 => Self::Dos,
3 => Self::Unix,
_ => Self::Unknown,
}
}
}

impl From<System> for u8 {
fn from(system: System) -> Self {
match system {
System::Dos => 0,
System::Unix => 3,
System::Unknown => 4,
}
}
}

/// Representation of a moment in time.
///
/// Zip files use an old format from DOS to store timestamps,
Expand Down

0 comments on commit 769fff2

Please sign in to comment.