From 2c32069d9ecd0f5f0b599b7ef4c5e3146cba75e7 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 29 Sep 2024 14:25:30 -0600 Subject: [PATCH] Fix the serde feature after #51 We should really add a CI configuration that includes that feature. --- src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 8c69eab..57ab3e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -112,7 +112,6 @@ mod subject { /// Represents a user subject #[derive(Clone, Debug, PartialEq, Eq, Hash)] - #[cfg_attr(feature = "serialize", derive(serde::Serialize))] pub struct User(pub Uid); impl User { @@ -143,6 +142,15 @@ mod subject { } } + #[cfg(feature = "serialize")] + impl serde::Serialize for User { + fn serialize(&self, serializer: S) -> Result + where S: serde::Serializer + { + self.0.as_raw().serialize(serializer) + } + } + impl<'a> From<&'a User> for String { fn from(user: &'a User) -> String { format!("user:{}", user.0)