From 021634785b7c3b82c1203f490813008a95dffa1e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 24 Jul 2026 23:32:04 +0100 Subject: Store list of shared values in example --- examples/11-transient-0/output/rust/src/gen/data.rs | 2 +- .../output/rust/src/gen/data/transient_0.rs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'examples/11-transient-0/output/rust/src/gen') diff --git a/examples/11-transient-0/output/rust/src/gen/data.rs b/examples/11-transient-0/output/rust/src/gen/data.rs index df221bb..75efcc8 100644 --- a/examples/11-transient-0/output/rust/src/gen/data.rs +++ b/examples/11-transient-0/output/rust/src/gen/data.rs @@ -91,5 +91,5 @@ pub struct StructWithSum { #[derive(Debug, PartialEq)] pub struct StructWithShared { - pub inner: ::std::sync::Arc::, + pub inner: ::std::vec::Vec::<::std::sync::Arc::>, } diff --git a/examples/11-transient-0/output/rust/src/gen/data/transient_0.rs b/examples/11-transient-0/output/rust/src/gen/data/transient_0.rs index 52ae7e1..b2f78c2 100644 --- a/examples/11-transient-0/output/rust/src/gen/data/transient_0.rs +++ b/examples/11-transient-0/output/rust/src/gen/data/transient_0.rs @@ -223,11 +223,23 @@ pub fn decode_struct_with_sum(reader: &mut impl std::io::Read) -> ::std::io::Res } pub fn encode_struct_with_shared(value: &crate::data::StructWithShared, writer: &mut impl std::io::Write) -> ::std::io::Result::<()> { - crate::data::transient_0::encode_struct_with_int_32((&value.inner).as_ref(), writer)?; + { + crate::transient_0::encode_int_64(&(((&value.inner).len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?, writer)?; + for element in &value.inner { + crate::data::transient_0::encode_struct_with_int_32(element.as_ref(), writer)?; + }; + }; ::std::io::Result::Ok(()) } pub fn decode_struct_with_shared(reader: &mut impl std::io::Read) -> ::std::io::Result:: { - let inner = ::std::sync::Arc::new(crate::data::transient_0::decode_struct_with_int_32(reader)?); + let inner = { + let len = crate::transient_0::decode_int_64(reader)?; + let mut elements = ::std::vec::Vec::with_capacity((len.try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?); + for _ in 0..len { + elements.push(::std::sync::Arc::new(crate::data::transient_0::decode_struct_with_int_32(reader)?)); + }; + elements + }; std::io::Result::Ok(crate::data::StructWithShared { inner: inner }) } -- cgit v1.2.3