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

Move Input and Output traits to a separate crate codec-io #122

Closed
wants to merge 6 commits into from

Commits on Jul 8, 2019

  1. Move Input and Output traits to a separate crate codec-io

    We will eventually face the issue of dealing with multiple binary encoding formats (such as ssz). In those situations, it is apparent that serde's model (using one `Serialize` and `Deserialize` trait for everything) is not sufficient. For example, U256 needs to be serialized as string in json, while as bytearray in SCALE and ssz. This is not possible to be represented by basic Rust structures.
    
    Instead, we need to define Encode/Decode traits for each format we want to encode (have `scale::Encode`, `ssz::Encode`, etc). Those definitions can share common traits `Input` and `Output`. In this PR, I moved those two traits into a separate crate `codec-io` to make it reusable.
    
    Note that I also generalized `Error` -- in some other encoding libraries we may not want to represent Error as solely `&str` or unit type and want to actually derive the actual error and pass it to library user. This requires changing `Decode` trait in parity-codec to have an extra bound `From<I::Error>`, which is a breaking change.
    sorpaas committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    cc74d80 View commit details
    Browse the repository at this point in the history
  2. Update io/src/lib.rs

    Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
    sorpaas and bkchr committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    2f3a8ec View commit details
    Browse the repository at this point in the history
  3. Update derive/src/encode.rs

    Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
    sorpaas and bkchr committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    ca4de9b View commit details
    Browse the repository at this point in the history
  4. Update derive/src/encode.rs

    Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
    sorpaas and bkchr committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    b11181b View commit details
    Browse the repository at this point in the history
  5. Revert version bump

    sorpaas committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    1aabfbc View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    760695e View commit details
    Browse the repository at this point in the history