diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-14 22:36:32 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-14 22:36:32 +0100 |
| commit | d14b7d028aec3d491d9f162fc84aa8f4e51ec814 (patch) | |
| tree | 0bebdcaddea1fc501b4b3aef50bfd1510d9d7640 /examples/10-transient-0/output/rust/src/gen | |
| parent | edcaf92f6189a9f1af4978606d4948b56aca07b1 (diff) | |
Support struct with Int32 in rust-transient-0
Diffstat (limited to 'examples/10-transient-0/output/rust/src/gen')
| -rw-r--r-- | examples/10-transient-0/output/rust/src/gen/data.rs | 84 | ||||
| -rw-r--r-- | examples/10-transient-0/output/rust/src/gen/data/transient_0.rs | 149 |
2 files changed, 233 insertions, 0 deletions
diff --git a/examples/10-transient-0/output/rust/src/gen/data.rs b/examples/10-transient-0/output/rust/src/gen/data.rs new file mode 100644 index 0000000..814e4ca --- /dev/null +++ b/examples/10-transient-0/output/rust/src/gen/data.rs @@ -0,0 +1,84 @@ +// Generated by hobgoblin. + +#[derive(Debug, PartialEq)] +pub struct StructWithBool { + pub a: ::core::primitive::bool, + pub b: ::core::primitive::bool, +} + +#[derive(Debug, PartialEq)] +pub struct StructWithInt32 { + pub a: ::core::primitive::i32, + pub b: ::core::primitive::i32, +} + +#[derive(Debug, PartialEq)] +pub struct StructWithInt64 { + pub a: ::core::primitive::i64, + pub b: ::core::primitive::i64, +} + +#[derive(Debug, PartialEq)] +pub struct StructWithString { + pub a: ::std::string::String, + pub b: ::std::string::String, +} + +#[derive(Debug, PartialEq)] +pub struct OuterStruct { + pub inner: crate::data::InnerStruct, + pub c: ::core::primitive::i32, +} + +#[derive(Debug, PartialEq)] +pub struct InnerStruct { + pub a: ::core::primitive::i32, + pub b: ::core::primitive::i32, +} + +#[derive(Debug, PartialEq)] +pub struct StructWithList { + pub a: ::std::vec::Vec::<::core::primitive::i64>, + pub b: ::std::vec::Vec::<crate::data::InnerStruct>, +} + +#[derive(Debug, PartialEq)] +pub struct StructWithOption { + pub a: ::std::option::Option::<::core::primitive::i64>, + pub b: ::std::option::Option::<crate::data::InnerStruct>, +} + +#[derive(Debug, PartialEq)] +pub enum EnumWithVariants { + Zero, + One, + Two, +} + +#[derive(Debug, PartialEq)] +pub enum SumWithVariants { + VariantOne(crate::data::VariantOne), + VariantTwo(crate::data::VariantTwo), +} + +impl ::std::convert::From::<crate::data::VariantOne> for crate::data::SumWithVariants { + fn from(value: crate::data::VariantOne) -> Self { + Self::VariantOne(value) + } +} + +impl ::std::convert::From::<crate::data::VariantTwo> for crate::data::SumWithVariants { + fn from(value: crate::data::VariantTwo) -> Self { + Self::VariantTwo(value) + } +} + +#[derive(Debug, PartialEq)] +pub struct VariantOne { + pub a: ::core::primitive::i32, +} + +#[derive(Debug, PartialEq)] +pub struct VariantTwo { + pub a: ::core::primitive::i64, +} diff --git a/examples/10-transient-0/output/rust/src/gen/data/transient_0.rs b/examples/10-transient-0/output/rust/src/gen/data/transient_0.rs new file mode 100644 index 0000000..e899c4c --- /dev/null +++ b/examples/10-transient-0/output/rust/src/gen/data/transient_0.rs @@ -0,0 +1,149 @@ +// Generated by hobgoblin. + +pub fn encode_struct_with_bool(value: &crate::data::StructWithBool, writer: &mut impl std::io::Write) { + todo!(); + todo!(); +} + +pub fn decode_struct_with_bool(reader: &mut impl std::io::Read) -> crate::data::StructWithBool { + let a = todo!(); + let b = todo!(); + crate::data::StructWithBool { a: a, b: b } +} + +pub fn encode_struct_with_int_32(value: &crate::data::StructWithInt32, writer: &mut impl std::io::Write) { + writer.write_all(&value.a.to_le_bytes()); + writer.write_all(&value.b.to_le_bytes()); +} + +pub fn decode_struct_with_int_32(reader: &mut impl std::io::Read) -> crate::data::StructWithInt32 { + let a = { + let bytes = { + let mut bytes = [0; 4]; + reader.read_exact(&mut bytes); + bytes + }; + i32::from_le_bytes(bytes) + }; + let b = { + let bytes = { + let mut bytes = [0; 4]; + reader.read_exact(&mut bytes); + bytes + }; + i32::from_le_bytes(bytes) + }; + crate::data::StructWithInt32 { a: a, b: b } +} + +pub fn encode_struct_with_int_64(value: &crate::data::StructWithInt64, writer: &mut impl std::io::Write) { + todo!(); + todo!(); +} + +pub fn decode_struct_with_int_64(reader: &mut impl std::io::Read) -> crate::data::StructWithInt64 { + let a = todo!(); + let b = todo!(); + crate::data::StructWithInt64 { a: a, b: b } +} + +pub fn encode_struct_with_string(value: &crate::data::StructWithString, writer: &mut impl std::io::Write) { + todo!(); + todo!(); +} + +pub fn decode_struct_with_string(reader: &mut impl std::io::Read) -> crate::data::StructWithString { + let a = todo!(); + let b = todo!(); + crate::data::StructWithString { a: a, b: b } +} + +pub fn encode_outer_struct(value: &crate::data::OuterStruct, writer: &mut impl std::io::Write) { + todo!(); + writer.write_all(&value.c.to_le_bytes()); +} + +pub fn decode_outer_struct(reader: &mut impl std::io::Read) -> crate::data::OuterStruct { + let inner = todo!(); + let c = { + let bytes = { + let mut bytes = [0; 4]; + reader.read_exact(&mut bytes); + bytes + }; + i32::from_le_bytes(bytes) + }; + crate::data::OuterStruct { inner: inner, c: c } +} + +pub fn encode_inner_struct(value: &crate::data::InnerStruct, writer: &mut impl std::io::Write) { + writer.write_all(&value.a.to_le_bytes()); + writer.write_all(&value.b.to_le_bytes()); +} + +pub fn decode_inner_struct(reader: &mut impl std::io::Read) -> crate::data::InnerStruct { + let a = { + let bytes = { + let mut bytes = [0; 4]; + reader.read_exact(&mut bytes); + bytes + }; + i32::from_le_bytes(bytes) + }; + let b = { + let bytes = { + let mut bytes = [0; 4]; + reader.read_exact(&mut bytes); + bytes + }; + i32::from_le_bytes(bytes) + }; + crate::data::InnerStruct { a: a, b: b } +} + +pub fn encode_struct_with_list(value: &crate::data::StructWithList, writer: &mut impl std::io::Write) { + todo!(); + todo!(); +} + +pub fn decode_struct_with_list(reader: &mut impl std::io::Read) -> crate::data::StructWithList { + let a = todo!(); + let b = todo!(); + crate::data::StructWithList { a: a, b: b } +} + +pub fn encode_struct_with_option(value: &crate::data::StructWithOption, writer: &mut impl std::io::Write) { + todo!(); + todo!(); +} + +pub fn decode_struct_with_option(reader: &mut impl std::io::Read) -> crate::data::StructWithOption { + let a = todo!(); + let b = todo!(); + crate::data::StructWithOption { a: a, b: b } +} + +pub fn encode_variant_one(value: &crate::data::VariantOne, writer: &mut impl std::io::Write) { + writer.write_all(&value.a.to_le_bytes()); +} + +pub fn decode_variant_one(reader: &mut impl std::io::Read) -> crate::data::VariantOne { + let a = { + let bytes = { + let mut bytes = [0; 4]; + reader.read_exact(&mut bytes); + bytes + }; + i32::from_le_bytes(bytes) + }; + crate::data::VariantOne { a: a } +} + +pub fn encode_variant_two(value: &crate::data::VariantTwo, writer: &mut impl std::io::Write) { + todo!(); +} + +pub fn decode_variant_two(reader: &mut impl std::io::Read) -> crate::data::VariantTwo { + let a = todo!(); + crate::data::VariantTwo { a: a } +} |
