From 4e88f104c5d2bba2fb9c391ed046869065bb0b45 Mon Sep 17 00:00:00 2001 From: James Munns Date: Tue, 12 Nov 2019 00:54:05 +0100 Subject: [PATCH] Add proof of concept serde support with PathBuf --- Cargo.toml | 5 +++++ src/path/pathbuf.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index c1c6865..45ea88e 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 56a63a4..f7b9f61 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, }