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

Remove serde impls for Fixed/Signed types #168

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions pb-jelly-gen/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ impl<'a, 'ctx> CodeWriter<'a, 'ctx> {
let ctx = self;
ctx.write_comments(ctx.source_code_info_by_scl.get(scl).copied());
if ctx.derive_serde {
ctx.write("#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, Deserialize, Serialize)]");
ctx.write("#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, ::serde_derive::Deserialize, ::serde_derive::Serialize)]");
} else {
ctx.write("#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]");
}
Expand Down Expand Up @@ -1035,7 +1035,7 @@ impl<'a, 'ctx> CodeWriter<'a, 'ctx> {
// Generate an open enum
ctx.write_comments(ctx.source_code_info_by_scl.get(scl).copied());
if ctx.derive_serde {
ctx.write("#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]");
ctx.write("#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, ::serde_derive::Deserialize, ::serde_derive::Serialize)]");
} else {
ctx.write("#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]");
}
Expand Down Expand Up @@ -1210,7 +1210,7 @@ impl<'a, 'ctx> CodeWriter<'a, 'ctx> {

let mut derives = vec!["Clone", "Debug", "PartialEq"];
if ctx.derive_serde {
derives.extend(["Deserialize", "Serialize"]);
derives.extend(["::serde_derive::Deserialize", "::serde_derive::Serialize"]);
}

let impls = &ctx.ctx.impls_by_msg[&ProtoType::new(
Expand Down Expand Up @@ -2544,16 +2544,12 @@ impl<'a> Context<'a> {

all_deps.remove("std");

let mut features: IndexMap<&str, &str> = [
("serde", r#"features=["serde_derive"]"#),
("compact_str", r#"features=["bytes"]"#),
]
.iter()
.copied()
.collect();
let mut features: IndexMap<&str, &str> =
[("compact_str", r#"features=["bytes"]"#)].iter().copied().collect();

if derive_serde {
all_deps.insert("serde");
all_deps.insert("serde_derive");
features.insert("compact_str", r#"features=["bytes", "serde"]"#);
}

Expand Down Expand Up @@ -2588,18 +2584,19 @@ impl<'a> Context<'a> {
all_deps.remove("std");

let mut features: BTreeMap<&str, String> = BTreeMap::new();
features.insert("serde", "features=[\"serde_derive\"]".to_string());
features.insert("compact_str", "features=[\"bytes\"]".to_string());

if derive_serde {
all_deps.insert("serde");
all_deps.insert("serde_derive");
features.insert("compact_str", "features=[\"bytes\", \"serde\"]".to_string());
}

let mut versions: IndexMap<&str, String> = IndexMap::new();
versions.insert("lazy_static", "version = \"1.4.0\"".to_string());
versions.insert("pb-jelly", "version = \"0.0.16\"".to_string());
versions.insert("serde", "version = \"1.0\"".to_string());
versions.insert("serde_derive", "version = \"1.0\"".to_string());
versions.insert("bytes", "version = \"1.0\"".to_string());
versions.insert("compact_str", "version = \"0.5\"".to_string());

Expand Down
1 change: 0 additions & 1 deletion pb-jelly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ categories = ["encoding", "parsing", "web-programming"]
byteorder = "1.4"
bytes = "1.0"
compact_str = { version = "0.5", features = ["bytes"] }
serde = { version = "1.0", features = ["derive"] }
12 changes: 6 additions & 6 deletions pb-jelly/src/base_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl Message for i64 {

impl Reflection for i64 {}

#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Signed64(pub i64);

impl Signed64 {
Expand Down Expand Up @@ -259,7 +259,7 @@ impl DerefMut for Signed64 {
}
}

#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Signed32(pub i32);

impl Signed32 {
Expand Down Expand Up @@ -306,7 +306,7 @@ impl DerefMut for Signed32 {
}
}

#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Fixed64(pub u64);

impl Message for Fixed64 {
Expand Down Expand Up @@ -342,7 +342,7 @@ impl DerefMut for Fixed64 {
}
}

#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Fixed32(pub u32);

impl Message for Fixed32 {
Expand Down Expand Up @@ -378,7 +378,7 @@ impl DerefMut for Fixed32 {
}
}

#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Sfixed64(pub i64);

impl Message for Sfixed64 {
Expand Down Expand Up @@ -414,7 +414,7 @@ impl DerefMut for Sfixed64 {
}
}

#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Sfixed32(pub i32);

impl Message for Sfixed32 {
Expand Down
3 changes: 0 additions & 3 deletions pb-jelly/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
#![allow(clippy::cast_possible_truncation)]
#![allow(clippy::cast_possible_wrap)]

#[macro_use]
extern crate serde;

use std::any::Any;
use std::collections::BTreeMap;
use std::default::Default;
Expand Down
Loading