Skip to content
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

Add serde feature for faster-hex #28

Merged
merged 2 commits into from
Mar 29, 2023

Conversation

eval-exec
Copy link
Collaborator

@eval-exec eval-exec commented Mar 1, 2023

This PR want to close #25

We can use faster_hex with serde now, just add #[serde(with = "faster_hex")] above the field of the struct, like:

#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
struct Simple {
    #[serde(with = "faster_hex")]
    bar: Vec<u8>,
}

There are 6 mod:

  1. faster_hex::withpfx_ignorecase
    // Serialize with 0x-prefixed and lower case result. When deserializing, expect 0x-prefixed and don't care case
  2. faster_hex::nopfx_ignorecase
    // Serialize without 0x-prefixed and lower case result. When deserializing, expect no 0x-prefixed and don't care case
  3. faster_hex::withpfx_lowercase
    // Serialize with 0x-prefixed and lower case result. When deserializing, expect 0x-prefixed and lower case
  4. faster_hex::nopfx_lowercase
    // Serialize without 0x-prefixed and lower case result. When deserializing, expect no 0x-prefixed and lower case
  5. faster_hex::withpfx_uppercase
    // Serialize with 0x-prefixed and upper case result. When deserializing, expect 0x-prefixed and upper case
  6. faster_hex::nopfx_uppercase
    // Serialize without 0x-prefixed and lower case result. When deserializing, expect no 0x-prefixed and upper case

Note: #[serde(with = "faster_hex")] is equal to #[serde(with = "faster_hex::withpfx_ignorecase")]

@eval-exec eval-exec marked this pull request as draft March 1, 2023 03:36
@eval-exec eval-exec force-pushed the feat/serde branch 2 times, most recently from 82e35f8 to 65e9cf8 Compare March 2, 2023 06:31
Signed-off-by: Eval EXEC <execvy@gmail.com>
@eval-exec eval-exec changed the title [WIP] Add serde feature for faster-hex Add serde feature for faster-hex Mar 21, 2023
@eval-exec eval-exec marked this pull request as ready for review March 21, 2023 14:10
@eval-exec
Copy link
Collaborator Author

I think this PR is ready for review.

Cc. @zhangsoledad @quake

Signed-off-by: Eval EXEC <execvy@gmail.com>
@zhangsoledad zhangsoledad added this pull request to the merge queue Mar 29, 2023
@zhangsoledad zhangsoledad merged commit a4c06b3 into nervosnetwork:master Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

serde support
2 participants