Skip to content

Commit 4e88f10

Browse files
author
James Munns
committed
Add proof of concept serde support with PathBuf
1 parent 54371c2 commit 4e88f10

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ default = [
3333
"mio-uds",
3434
"num_cpus",
3535
"pin-project-lite",
36+
"serde-remotes",
3637
]
3738
docs = ["attributes", "unstable"]
3839
unstable = ["default", "broadcaster"]
3940
attributes = ["async-attributes"]
41+
serde-support = [
42+
"serde",
43+
]
4044
std = [
4145
"async-macros",
4246
"crossbeam-utils",
@@ -70,6 +74,7 @@ once_cell = { version = "1.2.0", optional = true }
7074
pin-project-lite = { version = "0.1", optional = true }
7175
pin-utils = { version = "0.1.0-alpha.4", optional = true }
7276
slab = { version = "0.4.2", optional = true }
77+
serde = { version = "1.0.0", optional = true, features = ["derive"] }
7378

7479
[dev-dependencies]
7580
femme = "1.2.0"

src/path/pathbuf.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ use crate::path::Path;
1313
use crate::prelude::*;
1414
#[cfg(feature = "unstable")]
1515
use crate::stream::{self, FromStream, IntoStream};
16+
#[cfg(feature = "serde-support")]
17+
use serde::{Serialize, Deserialize};
1618

1719
/// This struct is an async version of [`std::path::PathBuf`].
1820
///
1921
/// [`std::path::Path`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html
22+
#[cfg_attr(feature = "serde-support", derive(Serialize, Deserialize))]
2023
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2124
pub struct PathBuf {
25+
#[cfg_attr(feature = "serde-support", serde(flatten))]
2226
inner: std::path::PathBuf,
2327
}
2428

0 commit comments

Comments
 (0)