-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: blueprint-serde
crate
#429
Conversation
Will this be compatible with |
Yeah, that's the plan. I haven't made it |
We could have it be both too with the std feature. Just trying to keep us in the flow of doing so when we can, I.e it is probably more performant std but if it supports no-std then eventually we can use it in WASM. |
I can add an |
This crates lets us convert to and from the `Field` type easily with `serde`'s `Serialize` and `Deserialize` traits. This will allow for custom types in job parameters, as well as making it easier overall to convert between these types. The crate adds two public functions: * `to_field` - Convert any `Serialize` type into a `Field` * `from_field` - Attempt to convert a `Field` into a `DeserializeOwned` type While mostly useful for `Field::Struct`, one can also do: ```rust let age: u8 = gadget_blueprint_serde::from_field(Field::Uint8(40)).unwrap(); ``` Or conversion for any primitive type, if they wanted.
4dbc5ca
to
419c3f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, good job!
@@ -0,0 +1,104 @@ | |||
#![cfg_attr(feature = "std", no_std)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some top-level crate docs could be useful, with some examples and how to use them.
This crates lets us convert to and from the
Field
type easily withserde
'sSerialize
andDeserialize
traits. This will allow for custom types in job parameters, as well as making it easier overall to convert between these types.The crate adds two public functions:
to_field
- Convert anySerialize
type into aField
from_field
- Attempt to convert aField
into aDeserializeOwned
typeField::Struct
example:While mostly useful for
Field::Struct
, one can also do:Or conversion for any primitive type, if they wanted.