From e4ac6b36d3c633b3ec943ec279b82f79508b0f06 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 18 Jul 2026 10:27:39 +0100 Subject: Support Bool values in rust-transient-0 --- .../output/rust/src/gen/transient_0.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'examples/10-transient-0/output/rust/src/gen') diff --git a/examples/10-transient-0/output/rust/src/gen/transient_0.rs b/examples/10-transient-0/output/rust/src/gen/transient_0.rs index 024ad03..68aa0eb 100644 --- a/examples/10-transient-0/output/rust/src/gen/transient_0.rs +++ b/examples/10-transient-0/output/rust/src/gen/transient_0.rs @@ -1,12 +1,28 @@ // Generated by hobgoblin. pub fn encode_bool(value: &::core::primitive::bool, writer: &mut impl std::io::Write) -> ::std::io::Result::<()> { - todo!(); + if *value { + writer.write_all(&1u8.to_le_bytes())?; + } else { + writer.write_all(&0u8.to_le_bytes())?; + }; ::std::io::Result::Ok(()) } pub fn decode_bool(reader: &mut impl std::io::Read) -> ::std::io::Result::<::core::primitive::bool> { - std::io::Result::Ok(todo!()) + let int_value = { + let bytes = { + let mut bytes = [0; 1]; + reader.read_exact(&mut bytes)?; + bytes + }; + u8::from_le_bytes(bytes) + }; + std::io::Result::Ok(if int_value == 0 { + false + } else { + true + }) } pub fn encode_int_32(value: &::core::primitive::i32, writer: &mut impl std::io::Write) -> ::std::io::Result::<()> { -- cgit v1.2.3