-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support serde
attributes
#201
Comments
@TheBestTvarynka Thanks for the report! Yeah, at the moment nutype generates it's own Does your implementation of |
yes This is my use case: // https://github.com/TheBestTvarynka/Dataans/blob/582dd48b5e8f05f859d1b8d21db1b97f0c56cab7/crates/web-api-types/src/lib.rs#L14-L18
#[nutype(
validate(predicate = |token| !token.is_empty()),
derive(Debug, Serialize, Deserialize, AsRef, Deref, TryFrom),
)]
pub struct InvitationToken(Vec<u8>);
// https://github.com/TheBestTvarynka/Dataans/blob/582dd48b5e8f05f859d1b8d21db1b97f0c56cab7/crates/web-api-types/src/auth.rs#L10-L14
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SignUpRequest {
pub invitation_token: InvitationToken,
pub username: Username,
pub password: Password,
} This invitation token is a bunch of bytes, but I want these bytes to be base64 or hex-encoded in the resulting json. I found a workaround: I can set the |
Would you mind sharing your implementations of Unfortunately I cannot promise a fix for this quickly. For now I'd suggest you to go maybe with your own manually implemented type. |
Something like this: github/TheBestTvarynka/crypto-helper/69dd4cd/src/serde.rs#L8-L37. I planned to copy-paste this code into my current project 😅 |
I have the same wish. Posting my use case s.t. you have something to work against when you find the time:
Then I'd like to use |
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:The compiler says
error: #[nutype] does not support this attribute.
. I also tried this one:As I understand, this is unsupported yet. Am I right?
The text was updated successfully, but these errors were encountered: