Skip to content

Commit

Permalink
Fix serialize method for structs with only dummy data
Browse files Browse the repository at this point in the history
  • Loading branch information
sorokya committed Dec 28, 2023
1 parent c224932 commit d45479d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "eolib"
version = "1.0.0-RC3"
version = "1.0.0-RC4"
authors = ["Richard Leek <richard@richardleek.com>"]
description = "A core rust library for writing applications related to Endless Online"
edition = "2021"
Expand Down
20 changes: 7 additions & 13 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,17 +600,11 @@ fn write_struct(
" /// Serializes a [{}] into the given [EoWriter] instance\n",
name
));
if field_count > 0 {
code.push_str(
" fn serialize(&self, writer: &mut EoWriter) -> Result<(), EoSerializeError> {\n",
);
write_struct_serialize(code, name, elements, enums, structs);
} else {
code.push_str(
" fn serialize(&self, _writer: &mut EoWriter) -> Result<(), EoSerializeError> {\n",
);
code.push_str(" Ok(())\n");
}
code.push_str(
" fn serialize(&self, writer: &mut EoWriter) -> Result<(), EoSerializeError> {\n",
);
write_struct_serialize(code, name, elements, enums, structs);

code.push_str(" }\n");
code.push_str(&format!(
" /// Deserializes a [{}] from an [EoReader] instance\n",
Expand Down Expand Up @@ -740,7 +734,7 @@ fn write_struct_deserialize(
structs: &[Struct],
) {
code.push_str(
" let current_chunked_readming_mode = reader.get_chunked_reading_mode();\n",
" let current_chunked_reading_mode = reader.get_chunked_reading_mode();\n",
);
code.push_str(" let mut data = Self::default();\n");

Expand Down Expand Up @@ -847,7 +841,7 @@ fn write_struct_deserialize(
_ => {}
}
}
code.push_str(" reader.set_chunked_reading_mode(current_chunked_readming_mode);\n");
code.push_str(" reader.set_chunked_reading_mode(current_chunked_reading_mode);\n");
code.push_str(" Ok(data)\n");
}

Expand Down

0 comments on commit d45479d

Please sign in to comment.