Comments (2)
I just released a new version of the crate with this fix included. Thanks for implementing the fix.
from serde_with.
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)
- Double option pattern with subserializer HOT 2
- bug: serde_json/arbitrary_precision + PickFirst causes issues HOT 2
- Enable std/alloc without other features like chrono HOT 4
- How to combine `double_option` and `serde_as`? HOT 2
- Confusing/Incorrect PickFirst behavior HOT 3
- Compilation fails for targets without `alloc::sync`/atomic pointers
- Wishlist: Blocked on upstream changes
- Suggestion(Seq): Map to Vector of structs HOT 5
- 2.3.0 breaks `HashMap` serialization as `Vec` of pairs with `bincode` HOT 2
- Better Document behavior of DurationSeconds HOT 3
- Deserialization doesn't work on hashmap if both generic parameters are constrainted with DeserializeAs types HOT 3
- `DefaultOnError` not behaving like the examples HOT 1
- applying serde_as to whole struct. HOT 6
- Performance of Bytes with bincode HOT 3
- Combine `DisplayFromStr` and `NoneAsEmptyString` HOT 1
- Document ordering of DisplayFromStr invocation HOT 3
- Investigate use of `cfg_eval`
- Hex with leading 0x HOT 1
- Use custom base64 alphabet? HOT 2
- Deserialization failure when using borrowed `&str` in `serde_conv!()` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serde_with.