-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cosmos-sdk-proto: add serde derive macros (#471)
Uses Informal's fork of `pbjson` to generate `serde` impls Co-authored-by: Tony Arcieri (iqlusion) <[email protected]>
- Loading branch information
1 parent
6755fa0
commit 7e55c1d
Showing
102 changed files
with
83,445 additions
and
10 deletions.
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 = "serde")] | ||
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 = "serde")] | ||
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 = "serde")] | ||
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.