-
Notifications
You must be signed in to change notification settings - Fork 124
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
cosmos-sdk-proto: add serde derive macros #471
Merged
Merged
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a2d1abc
add serde definitions
ash-burnt 8bfa16c
add pbjson
ash-burnt 11179f1
add wasmd, update plugins
ash-burnt 17d17d9
extern google types with pbjson-types
ash-burnt 702d384
compiles
ash-burnt 89cc500
patch validators policy for serde
ash-burnt 69dd4c9
different patch for serde
ash-burnt 5ebab1c
add more name definitions for authorizations
ash-burnt 0dde80f
updated with upstream tendermint changes
ash-burnt 9dae930
switch to informal pbjson
ash-burnt fda84ca
review notes
ash-burnt b716d6d
Update cosmos-sdk-proto/Cargo.toml
ash-burnt b7e04cc
remove comment
ash-burnt f9e43da
Merge branch 'feat/serde' of github.aaakk.us.kg-ash:burnt-labs/cosmos-rust in…
ash-burnt 8474c92
cargo changes
ash-burnt d36b12b
pull upstream
ash-burnt 0960168
formatting
ash-burnt e8b7d05
cosmwasm authorizations don't exist in this version
ash-burnt 304bc5d
bring in pbjson for serialization
ash-burnt 395d8d7
Update cosmos-sdk-proto/Cargo.toml
ash-burnt 39988e6
Update cosmos-sdk-proto/Cargo.toml
ash-burnt 608a337
move serialization into a feature tag
ash-burnt 368b109
change name to serde
ash-burnt 41b9a21
format
ash-burnt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.app.module.v1alpha1.serde.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// @generated | ||
#[cfg(feature = "serialization")] | ||
impl serde::Serialize for Module { | ||
#[allow(deprecated)] | ||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
use serde::ser::SerializeStruct; | ||
let len = 0; | ||
let struct_ser = serializer.serialize_struct("cosmos.app.module.v1alpha1.Module", len)?; | ||
struct_ser.end() | ||
} | ||
} | ||
#[cfg(feature = "serialization")] | ||
impl<'de> serde::Deserialize<'de> for Module { | ||
#[allow(deprecated)] | ||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error> | ||
where | ||
D: serde::Deserializer<'de>, | ||
{ | ||
const FIELDS: &[&str] = &[]; | ||
|
||
#[allow(clippy::enum_variant_names)] | ||
enum GeneratedField {} | ||
#[cfg(feature = "serialization")] | ||
impl<'de> serde::Deserialize<'de> for GeneratedField { | ||
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error> | ||
where | ||
D: serde::Deserializer<'de>, | ||
{ | ||
struct GeneratedVisitor; | ||
|
||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { | ||
type Value = GeneratedField; | ||
|
||
fn expecting( | ||
&self, | ||
formatter: &mut std::fmt::Formatter<'_>, | ||
) -> std::fmt::Result { | ||
write!(formatter, "expected one of: {:?}", &FIELDS) | ||
} | ||
|
||
#[allow(unused_variables)] | ||
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E> | ||
where | ||
E: serde::de::Error, | ||
{ | ||
Err(serde::de::Error::unknown_field(value, FIELDS)) | ||
} | ||
} | ||
deserializer.deserialize_identifier(GeneratedVisitor) | ||
} | ||
} | ||
struct GeneratedVisitor; | ||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { | ||
type Value = Module; | ||
|
||
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
formatter.write_str("struct cosmos.app.module.v1alpha1.Module") | ||
} | ||
|
||
fn visit_map<V>(self, mut map_: V) -> std::result::Result<Module, V::Error> | ||
where | ||
V: serde::de::MapAccess<'de>, | ||
{ | ||
while map_.next_key::<GeneratedField>()?.is_some() { | ||
let _ = map_.next_value::<serde::de::IgnoredAny>()?; | ||
} | ||
Ok(Module {}) | ||
} | ||
} | ||
deserializer.deserialize_struct( | ||
"cosmos.app.module.v1alpha1.Module", | ||
FIELDS, | ||
GeneratedVisitor, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There's a lot of serialization going on in this crate, both protobuf and now JSON.
How about:
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.
Done, and adjusted the code gen