AltSysrq / fourleaf

Serialisation format and library for Rust.
Apache License 2.0
9 stars 1 forks source link

Serde support #1

Open dtolnay opened 7 years ago

dtolnay commented 7 years ago

@AltSysrq do you have any sense of what functionality would be required from Serde before fourleaf could take advantage of Serde's serialize and deserialize traits?

The only one I could discern from the docs is zero-copy deserialization of &str and &[u8] which has already been merged in Serde and will be available in the next release:

#[derive(Serialize, Deserialize)]
struct S<'a, 'b, 'c, 'd, 'e> {
    // copied from the input
    w: String,

    // &str and &[u8] are always implicitly borrowed from the input
    x: &'a str,

    // other types require an attribute to opt into borrowing
    #[serde(borrow)]
    y: Cow<'b, str>,

    // can narrow down which lifetimes should be borrowed
    #[serde(borrow = "'c + 'd")]
    z: Z<'c, 'd, 'static, 'e>,
}
AltSysrq commented 7 years ago

Wow, serde appears to have progressed quite a bit. My complements in particular on the newer docs.

So, besides zero-copy support, the main things that come to mind (reading the release docs):

I'll definitely look into implementing this once zero-copy in serde lands. Thanks for bringing this to my attention! I didn't think anyone knew about this crate.

AltSysrq commented 7 years ago

Really sorry for taking so long on this, some personal stuff came up and then I forgot for a while.

I've been working on this off and on, and it looks like everything should be doable as-is. So serde support will probably come eventually; sooner, if some immediate need for it arises.