Deser: Rethinking Rust Serialization

45 points by asb


zupzup

I don't believe serde is the end all be all of serialization but it has proven itself as a stable and reliable ecosystem-default for about a decade.

For the shortcomings serde does have (nothing can hit every possible trade-off perfectly), there are plenty of alternatives in the ecosystem albeit with less out-of-the-box library-support. Switching hasn't really been a big issue in my experience when my requirements didn't match serde's trade offs.

So I don't believe serde needs to be "dethroned" and I personally would rather not rely on a library that, based on recent commit history, received hundreds of slop commits for something as fundamental and critical as serialization but to each their own, I guess.

dprkh
use deser::{Deserialize, Serialize};
use deser_encoding::Hex;
use deser_validate::{Check, NonEmpty, Range};

#[derive(Debug, Serialize, Deserialize)]
pub struct Config {
    // at least one 256-bit key, each written as hex
    #[deser(as = Check<NonEmpty, Vec<Hex>>)]
    secret_keys: Vec<[u8; 32]>,
}

I noticed that this example violates "parse, don't validate." Does this library still support newtypes?