Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify non-binary and binary data, take 2 #284

Closed
wants to merge 3 commits into from

Commits on Apr 15, 2024

  1. feat(socketioxide): unify non-binary and binary data

    This allows users to create a payload struct (that implements
    Serialize/Deserialize) that has any binary payload data embedded in the
    struct directly, rather than needing to look in a "side" Vec of payload
    data, and have to guess what order the binary payloads fit into their
    data model.
    
    To accomplish this, there are new Serializer and Deserializer
    implementations that mostly wrap the Ser/Deser impls provided for
    serde_json::Value.  Unfortunately serde_json doesn't expose everything
    necessary to do this in a truly simple way; some duplication of
    serde_json's functionality is needed.
    
    Closes Totodore#276.
    kelnos committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    c7fc53a View commit details
    Browse the repository at this point in the history
  2. feat(socketioxide): properly send binary payloads embedded in structs

    In order to reduce possible API-use confusion, ConfOperators and
    BroadcastOperators now has a new type param, for a new (sealed) trait,
    BinaryHolding, which "tells" the struct whether or not the user has
    added binary data or not.
    
    If the user has not added binary data, the operator will be
    WithoutBinary, and emit() and emit_with_ack() take a T: Serialize as
    usual, and those methods will attempt to extract any binary payloads
    from the user-provided struct before sending the event.
    
    If the user explicitly adds binary data (by calling the bin() method),
    they will get back a new instance of the operator that is WithBinary.
    Then the emit() and emit_with_ack() methods will take a
    serde_json::Value, which is expected to already have placeholder objects
    where any binary payload is supposed to be.
    kelnos committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    3d63a69 View commit details
    Browse the repository at this point in the history
  3. feat(socketio/packet): Add create_binary_placeholder()

    This is a convenience function so callers can create the non-binary data
    to go along with their binary payloads, in a way that doesn't require
    them to understand socketio protocol implementation details.
    kelnos committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    c4851b5 View commit details
    Browse the repository at this point in the history