From 70a88513042c70a076cc30d36e4f2685cf7a743f Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Mon, 13 Nov 2023 09:35:52 -0800 Subject: [PATCH] Fix param of Type::from_xdr_base64 (#180) --- lib/xdrgen/generators/rust.rb | 2 +- spec/output/generator_spec_rust/block_comments.x/MyXDR.rs | 2 +- spec/output/generator_spec_rust/const.x/MyXDR.rs | 2 +- spec/output/generator_spec_rust/enum.x/MyXDR.rs | 2 +- spec/output/generator_spec_rust/nesting.x/MyXDR.rs | 2 +- spec/output/generator_spec_rust/optional.x/MyXDR.rs | 2 +- spec/output/generator_spec_rust/struct.x/MyXDR.rs | 2 +- spec/output/generator_spec_rust/test.x/MyXDR.rs | 2 +- spec/output/generator_spec_rust/union.x/MyXDR.rs | 2 +- .../block_comments.x/MyXDR.rs | 2 +- .../generator_spec_rust_custom_str_impls/const.x/MyXDR.rs | 2 +- .../output/generator_spec_rust_custom_str_impls/enum.x/MyXDR.rs | 2 +- .../generator_spec_rust_custom_str_impls/nesting.x/MyXDR.rs | 2 +- .../generator_spec_rust_custom_str_impls/optional.x/MyXDR.rs | 2 +- .../generator_spec_rust_custom_str_impls/struct.x/MyXDR.rs | 2 +- .../output/generator_spec_rust_custom_str_impls/test.x/MyXDR.rs | 2 +- .../generator_spec_rust_custom_str_impls/union.x/MyXDR.rs | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/xdrgen/generators/rust.rb b/lib/xdrgen/generators/rust.rb index abe43ed28..5352d2963 100644 --- a/lib/xdrgen/generators/rust.rb +++ b/lib/xdrgen/generators/rust.rb @@ -231,7 +231,7 @@ def render_enum_of_all_types(out, types) } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust/block_comments.x/MyXDR.rs b/spec/output/generator_spec_rust/block_comments.x/MyXDR.rs index abddcacc4..cbd950c3d 100644 --- a/spec/output/generator_spec_rust/block_comments.x/MyXDR.rs +++ b/spec/output/generator_spec_rust/block_comments.x/MyXDR.rs @@ -2925,7 +2925,7 @@ impl Type { } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust/const.x/MyXDR.rs b/spec/output/generator_spec_rust/const.x/MyXDR.rs index 0ece96d3a..18b47560b 100644 --- a/spec/output/generator_spec_rust/const.x/MyXDR.rs +++ b/spec/output/generator_spec_rust/const.x/MyXDR.rs @@ -2860,7 +2860,7 @@ TypeVariant::TestArray2 => Box::new(ReadXdrIter::<_, TestArray2>::new(dec, r.lim } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust/enum.x/MyXDR.rs b/spec/output/generator_spec_rust/enum.x/MyXDR.rs index c68807e13..5066acafb 100644 --- a/spec/output/generator_spec_rust/enum.x/MyXDR.rs +++ b/spec/output/generator_spec_rust/enum.x/MyXDR.rs @@ -3245,7 +3245,7 @@ TypeVariant::Color2 => Box::new(ReadXdrIter::<_, Color2>::new(dec, r.limits.clon } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust/nesting.x/MyXDR.rs b/spec/output/generator_spec_rust/nesting.x/MyXDR.rs index e46f87d03..a71bb0182 100644 --- a/spec/output/generator_spec_rust/nesting.x/MyXDR.rs +++ b/spec/output/generator_spec_rust/nesting.x/MyXDR.rs @@ -3185,7 +3185,7 @@ TypeVariant::MyUnionTwo => Box::new(ReadXdrIter::<_, MyUnionTwo>::new(dec, r.lim } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust/optional.x/MyXDR.rs b/spec/output/generator_spec_rust/optional.x/MyXDR.rs index f78a42385..c54e9bc24 100644 --- a/spec/output/generator_spec_rust/optional.x/MyXDR.rs +++ b/spec/output/generator_spec_rust/optional.x/MyXDR.rs @@ -2891,7 +2891,7 @@ TypeVariant::HasOptions => Box::new(ReadXdrIter::<_, HasOptions>::new(dec, r.lim } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust/struct.x/MyXDR.rs b/spec/output/generator_spec_rust/struct.x/MyXDR.rs index 7e9798c99..d36ed07c5 100644 --- a/spec/output/generator_spec_rust/struct.x/MyXDR.rs +++ b/spec/output/generator_spec_rust/struct.x/MyXDR.rs @@ -2899,7 +2899,7 @@ TypeVariant::MyStruct => Box::new(ReadXdrIter::<_, MyStruct>::new(dec, r.limits. } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust/test.x/MyXDR.rs b/spec/output/generator_spec_rust/test.x/MyXDR.rs index 328208a8f..d1f590d66 100644 --- a/spec/output/generator_spec_rust/test.x/MyXDR.rs +++ b/spec/output/generator_spec_rust/test.x/MyXDR.rs @@ -4659,7 +4659,7 @@ TypeVariant::NesterNestedUnion => Box::new(ReadXdrIter::<_, NesterNestedUnion>:: } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust/union.x/MyXDR.rs b/spec/output/generator_spec_rust/union.x/MyXDR.rs index c2f5fc216..2cf3d387c 100644 --- a/spec/output/generator_spec_rust/union.x/MyXDR.rs +++ b/spec/output/generator_spec_rust/union.x/MyXDR.rs @@ -3268,7 +3268,7 @@ TypeVariant::IntUnion2 => Box::new(ReadXdrIter::<_, IntUnion2>::new(dec, r.limit } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust_custom_str_impls/block_comments.x/MyXDR.rs b/spec/output/generator_spec_rust_custom_str_impls/block_comments.x/MyXDR.rs index abddcacc4..cbd950c3d 100644 --- a/spec/output/generator_spec_rust_custom_str_impls/block_comments.x/MyXDR.rs +++ b/spec/output/generator_spec_rust_custom_str_impls/block_comments.x/MyXDR.rs @@ -2925,7 +2925,7 @@ impl Type { } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust_custom_str_impls/const.x/MyXDR.rs b/spec/output/generator_spec_rust_custom_str_impls/const.x/MyXDR.rs index 0ece96d3a..18b47560b 100644 --- a/spec/output/generator_spec_rust_custom_str_impls/const.x/MyXDR.rs +++ b/spec/output/generator_spec_rust_custom_str_impls/const.x/MyXDR.rs @@ -2860,7 +2860,7 @@ TypeVariant::TestArray2 => Box::new(ReadXdrIter::<_, TestArray2>::new(dec, r.lim } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust_custom_str_impls/enum.x/MyXDR.rs b/spec/output/generator_spec_rust_custom_str_impls/enum.x/MyXDR.rs index d310e30f4..31f640596 100644 --- a/spec/output/generator_spec_rust_custom_str_impls/enum.x/MyXDR.rs +++ b/spec/output/generator_spec_rust_custom_str_impls/enum.x/MyXDR.rs @@ -3245,7 +3245,7 @@ TypeVariant::Color2 => Box::new(ReadXdrIter::<_, Color2>::new(dec, r.limits.clon } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust_custom_str_impls/nesting.x/MyXDR.rs b/spec/output/generator_spec_rust_custom_str_impls/nesting.x/MyXDR.rs index c9a8c32b0..1c56daf4e 100644 --- a/spec/output/generator_spec_rust_custom_str_impls/nesting.x/MyXDR.rs +++ b/spec/output/generator_spec_rust_custom_str_impls/nesting.x/MyXDR.rs @@ -3185,7 +3185,7 @@ TypeVariant::MyUnionTwo => Box::new(ReadXdrIter::<_, MyUnionTwo>::new(dec, r.lim } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust_custom_str_impls/optional.x/MyXDR.rs b/spec/output/generator_spec_rust_custom_str_impls/optional.x/MyXDR.rs index c6ccf1cf3..e7606d38b 100644 --- a/spec/output/generator_spec_rust_custom_str_impls/optional.x/MyXDR.rs +++ b/spec/output/generator_spec_rust_custom_str_impls/optional.x/MyXDR.rs @@ -2891,7 +2891,7 @@ TypeVariant::HasOptions => Box::new(ReadXdrIter::<_, HasOptions>::new(dec, r.lim } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust_custom_str_impls/struct.x/MyXDR.rs b/spec/output/generator_spec_rust_custom_str_impls/struct.x/MyXDR.rs index 5dbb312d4..c569fd2de 100644 --- a/spec/output/generator_spec_rust_custom_str_impls/struct.x/MyXDR.rs +++ b/spec/output/generator_spec_rust_custom_str_impls/struct.x/MyXDR.rs @@ -2899,7 +2899,7 @@ TypeVariant::MyStruct => Box::new(ReadXdrIter::<_, MyStruct>::new(dec, r.limits. } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust_custom_str_impls/test.x/MyXDR.rs b/spec/output/generator_spec_rust_custom_str_impls/test.x/MyXDR.rs index 2d9a0dc95..08c843587 100644 --- a/spec/output/generator_spec_rust_custom_str_impls/test.x/MyXDR.rs +++ b/spec/output/generator_spec_rust_custom_str_impls/test.x/MyXDR.rs @@ -4659,7 +4659,7 @@ TypeVariant::NesterNestedUnion => Box::new(ReadXdrIter::<_, NesterNestedUnion>:: } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?; diff --git a/spec/output/generator_spec_rust_custom_str_impls/union.x/MyXDR.rs b/spec/output/generator_spec_rust_custom_str_impls/union.x/MyXDR.rs index 0390c3dc1..a6b641f07 100644 --- a/spec/output/generator_spec_rust_custom_str_impls/union.x/MyXDR.rs +++ b/spec/output/generator_spec_rust_custom_str_impls/union.x/MyXDR.rs @@ -3268,7 +3268,7 @@ TypeVariant::IntUnion2 => Box::new(ReadXdrIter::<_, IntUnion2>::new(dec, r.limit } #[cfg(feature = "base64")] - pub fn from_xdr_base64(v: TypeVariant, b64: String, limits: Limits) -> Result { + pub fn from_xdr_base64(v: TypeVariant, b64: impl AsRef<[u8]>, limits: Limits) -> Result { let mut b64_reader = Cursor::new(b64); let mut dec = Limited::new(base64::read::DecoderReader::new(&mut b64_reader, base64::STANDARD), limits); let t = Self::read_xdr_to_end(v, &mut dec)?;