Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the serde feature after fubarnetes#51
Browse files Browse the repository at this point in the history
We should really add a CI configuration that includes that feature.
asomers committed Sep 29, 2024

Verified

This commit was signed with the committer’s verified signature.
jnpkrn Jan Pokorný
1 parent b04c07d commit 2c32069
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
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)

0 comments on commit 2c32069

Please sign in to comment.