diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-08-08 17:48:37 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-08-08 17:48:37 +0100 |
| commit | 13ddee33304f55788615eb3e330fd07d37093909 (patch) | |
| tree | ae83fde1f092d101e836b63d3c29d0889f849939 /examples/15-transient-0/output/rust/src/data.rs | |
| parent | 8455bb19b7d4235e667cab9112aa276557969dcc (diff) | |
Add use of native type to transient-0 example
Diffstat (limited to 'examples/15-transient-0/output/rust/src/data.rs')
| -rw-r--r-- | examples/15-transient-0/output/rust/src/data.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/15-transient-0/output/rust/src/data.rs b/examples/15-transient-0/output/rust/src/data.rs index 7a0c4fa..6078fd0 100644 --- a/examples/15-transient-0/output/rust/src/data.rs +++ b/examples/15-transient-0/output/rust/src/data.rs @@ -1,5 +1,35 @@ include!("./gen/data.rs"); +#[derive(Clone, Debug, Hash, PartialEq)] +pub struct Native { + pub a: i32, + pub b: i32, +} + pub mod transient_0 { + use ::std::any::Any; + use ::std::sync::Arc; + use ::std::vec::Vec; + use super::Native; + include!("./gen/data/transient_0.rs"); + + pub fn encode_native( + value: &Native, + writer: &mut impl std::io::Write, + shared_values: &mut ::std::collections::HashMap::<usize, i64>, + ) -> std::io::Result<()> { + crate::transient_0::encode_int_32(&value.a, writer, shared_values)?; + crate::transient_0::encode_int_32(&value.b, writer, shared_values)?; + Ok(()) + } + + pub fn decode_native( + reader: &mut impl std::io::Read, + shared_values: &mut Vec<Arc::<dyn Any + Sync + Send>>, + ) -> std::io::Result<Native> { + let a = crate::transient_0::decode_int_32(reader, shared_values)?; + let b = crate::transient_0::decode_int_32(reader, shared_values)?; + Ok(Native { a, b }) + } } |
