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

Add Value type, with serde and scale impls #1

Merged
merged 21 commits into from May 23, 2022
Merged

Add Value type, with serde and scale impls #1

merged 21 commits into from May 23, 2022

Conversation

jsdw
Copy link
Collaborator

@jsdw jsdw commented May 18, 2022

  • The Value type is the simplest shape possible to be able to represent the data for arbitrary types generated from scale-info (it does not care about any type information; only that you don't lose any precision encoding and decoding things from/to Values given a specific type to encode/decode to/from).
  • Encoding values is fairly lenient w.r.t the shape of the value type; if the Value can be encoded into the type losslessly we attempt to allow it.
  • Serde impls exist to allow the Value type to be transformed from/to some serial format and static types (though at the time of writing, going from a static type to a scale value hasn't been implemented yet) (edit: I did add this).

The main use case for this crate offhand will be allowing subxt to work with dynamic values more, and be able to provide back a representation for scale encoded bytes that a static type may not exist for.

src/lib.rs Outdated
assert_eq!(result, 4);
}
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is part of subxt.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This file is part of subxt.
// This file is part of scale-value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh good spot; need to go around and change these copyright headers now :)

@jsdw jsdw changed the title Add value type, with serde and scale impls Add Value type, with serde and scale impls May 20, 2022
Copy link
Member

@ascjones ascjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jsdw jsdw merged commit a8b98cf into main May 23, 2022
@jsdw jsdw deleted the scale-value branch May 23, 2022 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants