diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-18 10:27:39 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-18 10:27:39 +0100 |
| commit | e4ac6b36d3c633b3ec943ec279b82f79508b0f06 (patch) | |
| tree | 67aee49b6ee6c1b0ae0aec85961f327c36ec6a10 /examples/10-transient-0/output/rust/src/gen/transient_0.rs | |
| parent | 25851fc06ab5b2271fb12ee35c5c181c1f9258aa (diff) | |
Support Bool values in rust-transient-0
Diffstat (limited to 'examples/10-transient-0/output/rust/src/gen/transient_0.rs')
| -rw-r--r-- | examples/10-transient-0/output/rust/src/gen/transient_0.rs | 20 |
1 files changed, 18 insertions, 2 deletions
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::<()> { |
