From 7eed843944a247a99e48bdb6f9dc3aac17d983c5 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 18 Jul 2026 19:32:20 +0100 Subject: Support options in rust-transient-0 --- .../output/rust/src/gen/data/transient_0.rs | 40 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'examples/10-transient-0/output/rust/src/gen/data') 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 index f8e9be0..1d65042 100644 --- 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 @@ -109,14 +109,46 @@ pub fn decode_struct_with_list(reader: &mut impl std::io::Read) -> ::std::io::Re } pub fn encode_struct_with_option(value: &crate::data::StructWithOption, writer: &mut impl std::io::Write) -> ::std::io::Result::<()> { - todo!(); - todo!(); + if (&value.a).is_some() { + { + crate::transient_0::encode_bool(&true, writer)?; + }; + { + crate::transient_0::encode_int_64(&((&value.a).as_ref()).unwrap(), writer)?; + }; + } else { + crate::transient_0::encode_bool(&false, writer)?; + }; + if (&value.b).is_some() { + { + crate::transient_0::encode_bool(&true, writer)?; + }; + { + crate::data::transient_0::encode_inner_struct(&((&value.b).as_ref()).unwrap(), writer)?; + }; + } else { + crate::transient_0::encode_bool(&false, writer)?; + }; ::std::io::Result::Ok(()) } pub fn decode_struct_with_option(reader: &mut impl std::io::Read) -> ::std::io::Result:: { - let a = todo!(); - let b = todo!(); + let a = { + let is_some = crate::transient_0::decode_bool(reader)?; + if is_some { + ::std::option::Option::Some(crate::transient_0::decode_int_64(reader)?) + } else { + ::std::option::Option::None + } + }; + let b = { + let is_some = crate::transient_0::decode_bool(reader)?; + if is_some { + ::std::option::Option::Some(crate::data::transient_0::decode_inner_struct(reader)?) + } else { + ::std::option::Option::None + } + }; std::io::Result::Ok(crate::data::StructWithOption { a: a, b: b }) } -- cgit v1.2.3