diff --git a/Cargo.toml b/Cargo.toml index c1c68655..45ea88ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,10 +33,14 @@ default = [ "mio-uds", "num_cpus", "pin-project-lite", + "serde-remotes", ] docs = ["attributes", "unstable"] unstable = ["default", "broadcaster"] attributes = ["async-attributes"] +serde-support = [ + "serde", +] std = [ "async-macros", "crossbeam-utils", @@ -70,6 +74,7 @@ once_cell = { version = "1.2.0", optional = true } pin-project-lite = { version = "0.1", optional = true } pin-utils = { version = "0.1.0-alpha.4", optional = true } slab = { version = "0.4.2", optional = true } +serde = { version = "1.0.0", optional = true, features = ["derive"] } [dev-dependencies] femme = "1.2.0" diff --git a/src/path/pathbuf.rs b/src/path/pathbuf.rs index 56a63a47..f7b9f61b 100644 --- a/src/path/pathbuf.rs +++ b/src/path/pathbuf.rs @@ -13,12 +13,16 @@ use crate::path::Path; use crate::prelude::*; #[cfg(feature = "unstable")] use crate::stream::{self, FromStream, IntoStream}; +#[cfg(feature = "serde-support")] +use serde::{Serialize, Deserialize}; /// This struct is an async version of [`std::path::PathBuf`]. /// /// [`std::path::Path`]: https://doc.rust-lang.org/std/path/struct.PathBuf.html +#[cfg_attr(feature = "serde-support", derive(Serialize, Deserialize))] #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct PathBuf { + #[cfg_attr(feature = "serde-support", serde(flatten))] inner: std::path::PathBuf, }