Skip to content

Support serde attributes #201

Open
Open
@TheBestTvarynka

Description

@TheBestTvarynka

Hi,
I like your library a lot and I use it regularly.

Today I tried to use serde attributes on my new-type struct but failed. Here is an example:

#[nutype(
    validate(predicate = |token| !token.is_empty()),
    derive(Debug, Serialize, Deserialize, AsRef, Deref, TryFrom),
)]
#[serde(serialize_with = "...", deserialize_with = "...")]
pub struct InvitationToken(Vec<u8>);

The compiler says error: #[nutype] does not support this attribute.. I also tried this one:

#[nutype(
    validate(predicate = |token| !token.is_empty()),
    derive(Debug, Serialize, Deserialize, AsRef, Deref, TryFrom),
)]
pub struct InvitationToken(#[serde(serialize_with = "...", deserialize_with = "...")] Vec<u8>);

As I understand, this is unsupported yet. Am I right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions