~tdeo

https://tadeo.ca

Trackers

~tdeo/serde_bare

Last active 2 months ago

#5 Support deserialising externally tagged enums 3 months ago

Comment by ~tdeo on ~tdeo/serde_bare

Hi, I'm not sure I understand. You can just remove your #[serde(tag = "protocol", content = "data", rename_all = "snake_case")] and it will be serialized correctly, into a BARE tagged union.

The only case where this should be a problem is when trying to use the same Serde implementations for multiple data formats, and you're using overrides to fit with an existing convention.

#5 Support deserialising externally tagged enums 3 months ago

Comment by ~tdeo on ~tdeo/serde_bare

Hi, there are some Serde features that only make sense in the context of self-describing serialization formats like JSON, YAML, and CBOR rather than non-self-describing formats like BARE or Bincode.

In BARE, enum variant names as well as struct fields are completely ignored, so the rename_all in your example has no effect with serde_bare.

Serialising this enum works and results in the equivalent of the following encoding schema:

type Payload {
    protocol: string
    data: data
}

This is actually not what happens, it actually becomes

{
    protocol: string
    data: {
        name: optional<string>
    }
}

when serializing Start and

{
    protocol: string
    data: {
        name: string
    }
}

when serializing Confirm.

While it's technically possible to deserialize such a message properly, I don't believe any BARE implementation can actually represent this as a native type.

When the derived Deserialize implementation goes to deserialize it, deserialize_identifier is called.

deserialize_identifier's documentation is:

[...] the name of a struct field or the discriminant of an enum variant.

In formats like JSON, these would both be represented as strings, but in BARE, struct fields are unnecessary (since fields must always be in order), and enum discriminants are simple uints.

It's not possible to know in advance whether we're deserializing a string or a uint, so serde_bare can't support this kind of use.

If you're looking to share Serialize/Deserialize implementations between BARE and other formats, it seems it's likely not possible for cases like this. See https://github.com/bincode-org/bincode/issues/272 for a similar issue with Bincode.

#4 Allow streaming deserialising / getting the remainder of slice 3 months ago

Comment by ~tdeo on ~tdeo/serde_bare

Hi, I think for slices you should be able to do this using std::io::Cursor's position() method, and using from_reader instead of from_slice.

I'm not sure if there's a convenient wrapper for other readers, though.

#3 Link to the ticket tracker in the README 3 months ago

on ~tdeo/serde_bare

REPORTED RESOLVED FIXED

#1 Add a way to get a schema from a type that implements Serialize 1 year, 15 days ago

Comment by ~tdeo on ~tdeo/serde_bare

I think this would be quite brittle.

  • It would only work with optional types if the supplied value
  • It wouldn't work on non-active enum variants.

And probably more. I think the schema to Rust code generation is a better path for this.

REPORTED RESOLVED WONT_FIX

#2 Add a way to parse a schema and generate code for it 1 year, 26 days ago

Ticket created by ~tdeo on ~tdeo/serde_bare

This could be done as a bang-style procedural macro or a function to call from your build.rs file. Not sure which to do yet.

#1 Add a way to get a schema from a type that implements Serialize 1 year, 26 days ago

Ticket created by ~tdeo on ~tdeo/serde_bare

#23 Unlisted pastes and private paste titles/filenames can be seen while logged out 1 year, 8 months ago

Ticket created by ~tdeo on ~sircmpwn/paste.sr.ht

Private pastes can't be viewed and throw an unauthorized error, but it does link to unlisted pastes.

#130 Invoices on billing page are in reverse order 1 year, 9 months ago

Ticket created by ~tdeo on ~sircmpwn/meta.sr.ht

Banner at the top of the page is was last paid 5 months ago instead of 2 days ago, and text for Your account will be automatically renewed at the end of the term. is on the oldest invoice rather than the newest.