Skip to content

Commit e79acba

Browse files
committed
Add optional serde dependency
1 parent 8554448 commit e79acba

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ description = "Decode, interpret, and display Unix file mode bits (even on non-U
77
license = "Apache-2.0"
88
repository = "https://github.com/sourcefrog/unix_mode"
99

10-
[dependencies]
10+
[features]
11+
serde = ["dep:serde"]
12+
13+
[dependencies.serde]
14+
version = "1.0"
15+
optional = true
16+
features = [ "derive" ]
1117

1218
[target.'cfg(unix)'.dev-dependencies]
1319
tempfile = "3.2"

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
//!
4444
//! # Changelog
4545
//!
46+
//! ## 0.1.4-pre
47+
//!
48+
//! * Optional feature `serde` allows serializing [Type], [Access], and [Accessor].
49+
//!
4650
//! ## 0.1.3
4751
//!
4852
//! * Add [Type] enum for matching the file type.
@@ -74,6 +78,7 @@ fn type_bits(mode: u32) -> u32 {
7478
/// assert_eq!(unix_mode::Type::from(0o0100640), unix_mode::Type::File);
7579
/// ```
7680
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
81+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7782
#[non_exhaustive]
7883
pub enum Type {
7984
/// A plain file.
@@ -119,6 +124,7 @@ impl From<u32> for Type {
119124

120125
/// Enum for specifying the context / "who" accesses in [is_allowed]
121126
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
127+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
122128
pub enum Accessor {
123129
/// Access by anyone other than the user or group.
124130
Other,
@@ -130,6 +136,7 @@ pub enum Accessor {
130136

131137
/// Enum for specifying the type of access in [is_allowed]
132138
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
139+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
133140
pub enum Access {
134141
/// Permission to "execute", broadly.
135142
///

0 commit comments

Comments
 (0)