GithubHelp home page GithubHelp logo

Comments (2)

jonasbb avatar jonasbb commented on May 24, 2024 1

I just released a new version of the crate with this fix included. Thanks for implementing the fix.

from serde_with.

jonasbb avatar jonasbb commented on May 24, 2024

Hi, thanks for the interest.
It seems that serialization already works with the existing Hex type, only deserialization is impossible since there is no [u8; N]: From<Vec<u8>> implementation.

Even disconnected from this issue, it might be worthwhile to see if the DeserializeAs implementation can be changed to something like this, since that would allow TryFrom in addition to all currently existing From implementations.
This also does not work for arrays though, since the TryFrom error does not implement Display.

impl<'de, T, E, FORMAT> DeserializeAs<'de, T> for Hex<FORMAT>
where
    T: TryFrom<Vec<u8>, Error = E>,
    E: Display,
    FORMAT: Format,

Therefore, I think the only way forward is to add another Hex-like type especially for array, a HexArray. Do you want to contribute this? The implementation in hex.rs is quite simple.
If you want to contribute base64 too, I would be happy to accept that too. Implementation wise it shouldn't differ too much from the hex type, except that there are different base64 character sets. But they can always be added later.

from serde_with.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.